Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
When generating a Key, the Account Name must be set.
When generating a Key, the Issuer must be set.
The user provided passcode length was not expected.
Error when attempting to convert the secret from base32 to raw bytes.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm int
Algorithm represents the hashing function to use in the HMAC operation needed for OTPs.
const ( // AlgorithmSHA1 should be used for compatibility with Google Authenticator. // // See https://git.ecn.io/ian/otp/issues/55 for additional details. AlgorithmSHA1 Algorithm = iota AlgorithmSHA256 AlgorithmSHA512 AlgorithmMD5 )
type Digits ¶
type Digits int
Digits represents the number of digits present in the user's OTP passcode. Six and Eight are the most common values.
func (Digits) Format ¶
Format converts an integer into the zero-filled size for this Digits.
func (Digits) Length ¶
Length returns the number of characters for this Digits.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents an TOTP or HTOP key.
func NewKeyFromURL ¶
NewKeyFromURL creates a new Key from an TOTP or HOTP url.
The URL format is documented here:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
func (*Key) AccountName ¶
AccountName returns the name of the user's account.
func (*Key) Algorithm ¶
Algorithm returns the algorithm used or the default (SHA1).
func (*Key) Digits ¶
Digits returns a tiny int representing the number of OTP digits.
func (*Key) Issuer ¶
Issuer returns the name of the issuing organization.
func (*Key) Period ¶
Period returns a tiny int representing the rotation time in seconds.
Source Files
¶
- otp.go