Documentation ¶
Index ¶
Constants ¶
const ( OTPTypeTOTP = "totp" OTPTypeHOTP = "hotp" )
const MaxOTPLength = 8
MaxOTPLength set the character length limit of the library
Variables ¶
This section is empty.
Functions ¶
func BuildURI ¶
func BuildURI(otpType, secret, accountName, issuerName, algorithm string, initialCount, digits, period int) string
BuildURI returns the provisioning URI for the OTP; works for either TOTP or HOTP. This can then be encoded in a QR Code and used to provision the Google Authenticator app. For module-internal use. See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
otpType: otp type, must in totp/hotp secret: the hotp/totp secret used to generate the URI accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator algorithm: the algorithm used in the OTP generation initialCount: starting counter value. Only works for hotp digits: the length of the OTP generated code. period: the number of seconds the OTP generator is set to expire every code.
returns: provisioning uri
Types ¶
type HOTP ¶
type HOTP struct {
*OTP
}
HOTP is the HMAC-based OTP counters.
func NewDefaultHOTP ¶
NewDefaultHOTP returns an HOTP struct with the given secret and set defaults. The digit count is 6, hasher SHA1 and format is decimal output.
func NewHOTP ¶
NewHOTP returns an HOTP struct. If hasher is set to nil, the hasher defaults to SHA1.
func (*HOTP) ProvisioningURI ¶
ProvisioningURI returns the provisioning URI for the OTP. This can then be encoded in a QR Code and used to provision an OTP app like Google Authenticator.
See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator initialCount: starting HMAC counter value
returns: provisioning URI
type TOTP ¶
type TOTP struct { *OTP // contains filtered or unexported fields }
TOTP is the time-based OTP counters.
func NewDefaultTOTP ¶
NewDefaultTOTP returns an TOTP struct with the given secret and set defaults. The digit count is 6, interval 30, hasher SHA1 and format is decimal output.
func NewTOTP ¶
NewTOTP returns an TOTP struct. If hasher is set to nil, the hasher defaults to SHA1.
func (*TOTP) NowWithExpiration ¶
NowWithExpiration generates the current time OTP and expiration time.
func (*TOTP) ProvisioningURI ¶
ProvisioningURI returns the provisioning URI for the OTP. This can then be encoded in a QR Code and used to provision an OTP app like Google Authenticator.
See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator
returns: provisioning URI