Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateBackupCodes ¶
GenerateBackupCodes creates n random backup codes in "XXXX-XXXX" format.
func HashBackupCode ¶
HashBackupCode returns a bcrypt hash of a backup code. The code is normalized to uppercase before hashing.
func ValidateCode ¶
ValidateCode checks whether a TOTP code is valid for the given secret. Uses a time window of ±1 period (30 seconds) for clock drift tolerance.
func VerifyBackupCode ¶
VerifyBackupCode checks a plaintext code against a bcrypt hash. The code is normalized to uppercase before comparison.
Types ¶
type Key ¶
type Key struct {
Secret string // Base32-encoded secret
URL string // otpauth:// provisioning URI for QR codes
}
Key wraps an OTP key with its secret and provisioning URI.
func GenerateKey ¶
GenerateKey creates a new TOTP secret for the given issuer and account. The issuer appears in the authenticator app (e.g. "RapidGo"). The account identifies the user (typically their email).