Documentation ¶
Overview ¶
package totp describes and provides needed types and interfaces to generate and validate 2fa codes easily
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSecretTooShort = Error{"secret is too short", 1, nil} ErrInvalidAlgorithm = Error{"secret is too short", 2, nil} )
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm uint
Algorithm enum holds the three standards algorithms for TOTP as per the [reference implementation](https://tools.ietf.org/html/rfc6238#appendix-A)
type Error ¶
Error is a custom error type
type TOTP ¶
type TOTP interface { // Generate a token for the provided timestamp Generate(time time.Time) (token string, err error) // Check if a token is valid, accounting for the skew field Check(token string, time time.Time) (valid bool, err error) // Sign a timestamp with a secret Sign(time time.Time) ([]byte, error) // Returns the secret as unpadded base32 Secret() string // Returns the standard URL for adding an account Url(label, issuer string) (url string, err error) // Generates a standard QrCode scannable by common apps, as its base64 representation Qr(label, issuer string) (base64 string, err error) }
TOTP holds informations as to how to generate an auth code and validate it. Its secret field is sensitive data, treat it accordingly
Click to show internal directories.
Click to hide internal directories.