feat: print the expiration time of TOTP code
This commit is contained in:
parent
9361d471ef
commit
17dac7d440
4 changed files with 13 additions and 5 deletions
|
@ -11,6 +11,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
|
||||
- Use go module to get this software
|
||||
- Generate random password
|
||||
- Print the expiration time of TOTP code
|
||||
|
||||
## v1.0.0 - 2019-07-12
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ gpm is passwords manager write in go and use AES-256 to encrypt the wallets
|
|||
|
||||
## Features
|
||||
|
||||
- generate OTP code
|
||||
- generate TOTP code
|
||||
- copy your login, password or otp in clipboard
|
||||
- manage multiple wallets
|
||||
- generate random password
|
||||
|
|
|
@ -267,7 +267,9 @@ func (c *Cli) copyEntry() {
|
|||
case "p":
|
||||
clipboard.WriteAll(entry.Password)
|
||||
case "o":
|
||||
clipboard.WriteAll(entry.OTPCode())
|
||||
code, time, _ := entry.OTPCode()
|
||||
fmt.Printf("this OTP code is available for %d seconds\n", time)
|
||||
clipboard.WriteAll(code)
|
||||
case "q":
|
||||
os.Exit(0)
|
||||
default:
|
||||
|
|
11
gpm/entry.go
11
gpm/entry.go
|
@ -58,7 +58,12 @@ func (e *Entry) GenerateID() {
|
|||
}
|
||||
|
||||
// OTPCode generate an OTP Code
|
||||
func (e *Entry) OTPCode() string {
|
||||
code, _ := totp.GenerateCode(e.OTP, time.Now())
|
||||
return code
|
||||
func (e *Entry) OTPCode() (string, int64, error){
|
||||
code, err := totp.GenerateCode(e.OTP, time.Now())
|
||||
time := 30 - (time.Now().Unix() % 30)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
|
||||
return code, time, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue