Documentation ¶
Overview ¶
Package totp generates a Timed One Time Password conforming to RFC6238
Index ¶
Constants ¶
View Source
const ( DefaultT0 = "1970-01-01T00:00:00Z" DefaultX = 30 DefaultCodeDigits = 8 CryptoSHA1 = "HMACSHA1" CryptoSHA256 = "HMACSHA256" CryptoSHA512 = "HMACSHA512" )
Variables ¶
View Source
var (
DIGIT_POWERS = []int64{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000}
)
Functions ¶
This section is empty.
Types ¶
type TOTPConfig ¶
type TOTPConfig struct { // Epoc time in standard format // eg: "1970-01-01T00:00:00Z" T0 string // Time step // eg 30.0 X int64 // shared secret K SecretK string // number of digits in OTP CodeDigits int // HMAC algorithm // enum{'HMACSHA1', 'HMACSHA256', 'HMACSHA512'} Crypto string }
func DefaultConfig ¶
func DefaultConfig(seed string) *TOTPConfig
Returns TOTP config object with defaults
func NewDefaultSHA1 ¶
func NewDefaultSHA1(seed string) *TOTPConfig
* Returns a TOTP config object that uses SHA1 for HMAC hashing and default values for `T0`, `X`, and `CodeDigits`.
The secret key still needs supplied by the user.
func NewDefaultSHA256 ¶
func NewDefaultSHA256(seed string) *TOTPConfig
* Returns a TOTP config object that uses SHA256 for HMAC hashing and default values for `T0`, `X`, and `CodeDigits`.
The secret key still needs supplied by the user.
func NewDefaultSHA512 ¶
func NewDefaultSHA512(seed string) *TOTPConfig
* Returns a TOTP config object that uses SHA512 for HMAC hashing and default values for `T0`, `X`, and `CodeDigits`.
The secret key still needs supplied by the user.
func (*TOTPConfig) GenerateTOTP ¶
func (otpConf *TOTPConfig) GenerateTOTP(date string) (string, error)
Click to show internal directories.
Click to hide internal directories.