Documentation ¶
Index ¶
- func GenerateDefault(secretKey string) (string, error)
- func GenerateSecret(length int) (string, error)
- func GenerateVerbose(secretKey string, hashAlgorithm string, digits byte, timeStep int64) (string, error)
- func Validate(secretKey string) error
- func ValidateVerbose(secretKey string, hashAlgorithm string, digits byte, timeStep int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateDefault ¶
GenerateDefault computes the time-based one-time password according to RFC 6238, using standard defaults: SHA1 as the hash function, 6 as the number of digits in the TOTP, 30 as the time-step, and 0 as T0, the start time. The secret key should be passed as a base-32-encoded string.
func GenerateSecret ¶
GenerateSecret returns a cryptographically secure base-32-encoded secret key of "length" underlying bytes.
func GenerateVerbose ¶
func GenerateVerbose(secretKey string, hashAlgorithm string, digits byte, timeStep int64) (string, error)
GenerateVerbose computes the time-based one-time password according to RFC 6238. Unlike GenerateDefault, it allows for choosing different hash functions, number of digits, and time-steps. "secretKey" is a base-32-encoded string. "hashAlgorithm" can take the values "SHA1", "SHA2-256", and "SHA2-512". "digits" has to be less than 11, since HOTP theoretically only supports a maximum of 10 digits. Even though T0, the "start time," should also be an input parameter, it seems like virtually no one uses anything other than T0 = 0. Therefore, I omitted it.
Types ¶
This section is empty.