totp

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package totp holds the recovery-code format helpers and an RFC 6238 code generator the auth engine and its tests share. Verification and secret handling live in the auth library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

func GenerateCode(secretBase32 string, now time.Time) (string, error)

GenerateCode returns the 6-digit TOTP for secretBase32 at the step containing now, with no clock-skew tolerance (that's Validate's job, which calls this internally): the symmetric counterpart callers need wherever something other than a live authenticator app must produce a code, e.g. tests exercising the confirm/verify handlers end to end.

func GenerateRecoveryCode

func GenerateRecoveryCode() (string, error)

GenerateRecoveryCode returns one single-use fallback code: 80 random bits, base32-encoded, grouped into four hyphenated blocks of four characters for readability when typed by hand.

func NormalizeRecoveryCode

func NormalizeRecoveryCode(code string) string

NormalizeRecoveryCode strips whitespace and hyphens and uppercases a recovery code, so a user's re-typed or copy-pasted input matches regardless of formatting differences from GenerateRecoveryCode's own output.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL