Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(secret string, t0, x int64, d uint32, currentTimeFn func() int64) (code uint32, timeRemaining uint64, err error)
Generate a TOTP value and the number of seconds remaining that the code is valid for t0 is the Unix time to start counting time steps (default value is 0, i.e., the Unix epoch) and is also a system parameter x represents the time step size in seconds (default value x = 30 seconds) and is a system parameter d represents the number of digits the TOTP code will be currentTimeFn is a function that should return the current unix time from the UTC time zone
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is a type that simplifies generation of TOTP codes by allowing configuration to be saved to the generator object.
func NewGenerator ¶
type Option ¶
type Option func(*Generator)
func WithCurrentTimeFn ¶
WithCurrentTimeFn sets the currentTimeFn to the specified function. Defaults to a function that returns time.Now().UTC().Unix()
func WithD ¶
WithD Option sets d to the specified value. Default value: 6 d represents the number of digits the OTP should be