Pad non-padded secrets. This lets us continue building on <= go1.8.
- Add tests for secrets using various padding methods. - Add a new method/test to append padding to non-padded secrets.
This commit is contained in:
4
totp.go
4
totp.go
@@ -150,9 +150,9 @@ func totpFromURL(u *url.URL) (*TOTP, string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
key, err := base32.StdEncoding.WithPadding(base32.NoPadding).DecodeString(secret)
|
||||
key, err := base32.StdEncoding.DecodeString(Pad(secret))
|
||||
if err != nil {
|
||||
// secret isn't base32 encoded
|
||||
// assume secret isn't base32 encoded
|
||||
key = []byte(secret)
|
||||
}
|
||||
otp := NewTOTP(key, 0, period, digits, algo)
|
||||
|
||||
Reference in New Issue
Block a user