Documentation
¶
Index ¶
Constants ¶
const ( OtpTypeTotp = "totp" OtpTypeHotp = "hotp" )
Variables ¶
This section is empty.
Functions ¶
func BuildUri ¶
func BuildUri(otpType, secret, accountName, issuerName, algorithm string, initialCount, digits, period int) string
BuildUri https://github.com/google/google-authenticator/wiki/Key-Uri-Format
func GenerateSecret ¶
func GenerateSecret() string
Types ¶
type Auth ¶
type Auth interface { //GenerateCode 生成验证码 GenerateCode(input int) string //VerifyCode 验证验证码 VerifyCode(input int, code string) bool }
Auth 认证信息
type HOTP ¶
type HOTP struct {
OTP
}
https://tools.ietf.org/html/rfc4226 page 5
func NewHOTP ¶
NewHotp create HOTP secret shared secret between client and server; each HOTP
generator has a different and unique secret K.
digits number of digits in an HOTP value hasher HMAC type
func (*HOTP) GenerateCode ¶
GenerateCode count 8-byte counter value, the moving factor. This counter
MUST be synchronized between the HOTP generator (client) and the HOTP validator (server).
func (*HOTP) ProvisioningUri ¶
ProvisioningUri create uri
type TOTP ¶
type TOTP struct { OTP // contains filtered or unexported fields }
Totp https://github.com/xycxmz/go-totp https://tools.ietf.org/html/rfc6238
func NewTOTP ¶
NewTOTP create TOTP secret shared secret digits number of digits interval a value that reflects a time hasher the crypto function to use
func (*TOTP) GenerateCode ¶
GenerateCode timestamp Unix time rfc6238
func (*TOTP) NowWithExpiration ¶
NowWithExpiration return code and expirationTime
func (*TOTP) ProvisioningUri ¶
ProvisioningUri create uri