Documentation ¶
Index ¶
- Constants
- func DecodeKey(key string) ([]byte, error)
- func EncodeKey(raw string, opt ...OptionFunc) string
- func EncodeKeyForIOS(raw string, opt ...OptionFunc) string
- func GenKey(opt ...OptionFunc) string
- func GenKeyForIOS(opt ...OptionFunc) string
- func GetCode(key string) (string, error)
- func GetCodeByRaw(key Key) (uint32, error)
- func PrintQR(content string) error
- type HashFunc
- type HashProvider
- type IHashFunc
- type Key
- type OptionFunc
- type Options
Constants ¶
View Source
const ( CodeDigits6 = 6 CodeDigits7 = 7 CodeDigits8 = 8 // TotpFormatter TOTP formatter // Example: // otpauth://totp/NAME?secret=KEY TotpFormatter = "otpauth://totp/%s?secret=%s" )
View Source
const ( BrightBlack = "\033[48;5;0m \033[0m" BrightWhite = "\033[48;5;7m \033[0m" )
Variables ¶
This section is empty.
Functions ¶
func EncodeKeyForIOS ¶
func EncodeKeyForIOS(raw string, opt ...OptionFunc) string
EncodeKeyForIOS returns encoded key for iOS
func GenKey ¶ added in v0.3.1
func GenKey(opt ...OptionFunc) string
GenKey returns random encoded key
func GenKeyForIOS ¶ added in v0.3.1
func GenKeyForIOS(opt ...OptionFunc) string
GenKeyForIOS returns random encoded key for iOS
func GetCodeByRaw ¶
GetCodeByRaw returns time based code by raw key
Types ¶
type HashFunc ¶ added in v0.3.1
type HashFunc struct {
Provider HashProvider
}
type HashProvider ¶ added in v0.3.1
type IHashFunc ¶ added in v0.3.1
func DefaultHashFunc ¶ added in v0.3.1
func DefaultHashFunc() IHashFunc
type OptionFunc ¶ added in v0.3.1
type OptionFunc func(opts *Options)
OptionFunc used to initialise
func WithDefaultHashFunc ¶ added in v0.3.1
func WithDefaultHashFunc() OptionFunc
WithDefaultHashFunc option to configure default hash function (sha1)
func WithHashFunc ¶ added in v0.3.1
func WithHashFunc(hashFunc IHashFunc) OptionFunc
WithHashFunc option to configure hash function
type Options ¶ added in v0.3.1
type Options struct { // HashFunc interface HashFunc IHashFunc // With hash WithHash bool // Key name KeyName string // With QR WithQR bool // Options for implementations of the interface can be stored in a context Context context.Context }
Options for func
func NewOptions ¶ added in v0.3.1
func NewOptions(optionFunc ...OptionFunc) Options
NewOptions new options
Click to show internal directories.
Click to hide internal directories.