Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedAlgorithm is returned when an unsupported algorithm is requested. ErrUnsupportedAlgorithm = errors.New("unsupported algorithm") )
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm int
Algorithm represents the hashing algorithm used in OTP generation.
type Option ¶
type Option func(*otpBuilder)
Option represents a configuration option for OTPs.
func WithAlgorithm ¶
WithAlgorithm sets the hashing algorithm for the OTP.
func WithDigits ¶
WithDigits sets the number of digits for the OTP.
func WithPeriod ¶
WithPeriod sets the time period in seconds for which a TOTP is valid. It configures the TOTP only.
type TOTP ¶
type TOTP struct {
// contains filtered or unexported fields
}
TOTP is Time-based One-Time Password algorithm implementation.
func (*TOTP) Algorithm ¶
Algorithm returns the hashing algorithm used in TOTP. If not set, it defaults to HmacSha1.
func (*TOTP) Digits ¶
Digits returns the number of digits in the generated TOTP. If not set, it defaults to 6.
func (*TOTP) Generate ¶
Generate generates a TOTP using the current time and the provided secret key.
func (*TOTP) GenerateWithTime ¶
GenerateWithTime generates a TOTP for the given time and secret key.