Documentation ¶
Index ¶
- Constants
- Variables
- type Algorithm
- type Digits
- type Host
- type Option
- func (opt *Option) Secret() string
- func (opt *Option) SetAlgorithm(a Algorithm) error
- func (opt *Option) SetDigits(d Digits) error
- func (opt *Option) SetIconURL(url string) error
- func (opt *Option) SetPeriod(period uint) error
- func (opt *Option) SetSecret(secret string) error
- func (opt *Option) SetSecretSize(secretSize uint) error
- type OtpAuth
Constants ¶
View Source
const (
// DefaultPeriod is a default value of period
DefaultPeriod = 30
)
Variables ¶
View Source
var ErrInvalidDigitsLength = errors.New("digits length unexpected")
ErrInvalidDigitsLength is an error when the digits length unexpected
View Source
var ErrOtpAuthOptionIsNil = errors.New("otpauth option is nil")
ErrOtpAuthOptionIsNil is an error when the otpauth option is nil
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm int
Algorithm is the hash function to use in the HMAC operation
const ( // AlgorithmSHA1 is a cryptographic hash function of SHA-1 AlgorithmSHA1 Algorithm = iota // AlgorithmSHA256 is a cryptographic hash function of SHA-256 AlgorithmSHA256 // AlgorithmSHA512 is a cryptographic hash function of SHA-512 AlgorithmSHA512 // AlgorithmMD5 is a cryptographic hash function of MD5 AlgorithmMD5 )
type Digits ¶
type Digits int
Digits is the number of digits
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is used when generates otpauth
func (*Option) SetAlgorithm ¶
SetAlgorithm sets the hash algorithm
func (*Option) SetIconURL ¶
SetIconURL sets a url of icon
func (*Option) SetSecretSize ¶
SetSecretSize sets a secretSize of the generated Secret
type OtpAuth ¶
type OtpAuth struct {
// contains filtered or unexported fields
}
OtpAuth has an optauth url and a secret key
func GenerateOtpAuth ¶
GenerateOtpAuth generates an otpAuth by passing issuer, account name and host
func GenerateOtpAuthWithOption ¶
func GenerateOtpAuthWithOption(issuer, accountName string, host Host, opt *Option) (*OtpAuth, error)
GenerateOtpAuthWithOption generates an otpAuth by passing option
Click to show internal directories.
Click to hide internal directories.