package
0.2.0
Repository: https://github.com/keinos/go-totp.git
Documentation: pkg.go.dev

# Functions

GenerateKey creates a new Key object with default options.
GenerateKeyCustom creates a new Key object with custom options.
GenerateKeyPEM creates a new Key object from a PEM formatted string.
GenerateKeyURI creates a new Key object from an TOTP uri/url.
GenKeyFromPEM creates a new Key object from a PEM formatted string.
GenKeyFromURI creates a new Key object from an TOTP uri/url.
NewAlgorithmID creates a new Algorithm object from an int.
NewAlgorithmStr creates a new Algorithm object from a string.
NewDigitsInt returns a new Digits object from the given value.
NewDigitsStr returns a new Digits object from the given string in decimal format.
NewOptions returns a new Options struct with the default values.
NewSecretBase32 creates a new Secret object from a base32 encoded string.
NewSecretBase62 creates a new Secret object from a base62 encoded string.
NewSecretBytes creates a new Secret object from a byte slice.
NewURI returns a new URI object.
StrToUint converts a string to an unsigned integer.
Validate returns true if the given passcode is valid for the secret and options at the current time.
ValidateCustom is similar to Validate() but allows you to specify the time to validate the passcode.
WithAlgorithm sets the Algorithm to use for HMAC (Default: Algorithm("SHA512")).
WithDigits sets the Digits to request TOTP code.
WithECDH sets a hashed ECDH shared secret as the TOTP secret from the given ECDH private key and the correspondent's ECDH public key.
WithPeriod sets the number of seconds a TOTP hash is valid for (Default: 30 seconds).
WithSecretSize sets the size of the generated Secret (Default: 128 bytes).
WithSkew sets the periods before or after the current time to allow.

# Constants

BlockTypeTOTP is the type of a PEM encoded data block.
DigitsEight is an alternative number of digits in a TOTP passcode.
DigitsSix is the default number of digits in a TOTP passcode.
FixLevel15 is a medium error correction level for QR codes, capable of recovering 15% of the data.
FixLevel25 is a qualified error correction level for QR codes, which can recover 25% of the data.
FixLevel30 is the highest level of error correction for QR codes, capable of recovering 30% of the data.
FixLevel7 is the lowest level of error correction for QR codes and can recover 7% of the data.
FixLevelDefault is the default error correction level for QR codes.
Google Authenticator does not work other than SHA1.
Google Authenticator does not work other than 6 digits.
30 seconds is recommended in RFC-6238.
128 Bytes.
± 1 period of tolerance.

# Structs

Key is a struct that holds the TOTP secret and its options.
Options is a struct that holds the options for a TOTP key.
QRCode is a struct that holds the information to create QR code image.

# Type aliases

Algorithm is a string that represents the algorithm used for HMAC.
Digits represents the number of digits present in the user's OTP passcode.
FixLevel is the error correction level for QR code.
Option is a function that applies an option to the given Options.
Secret is a byte slice that represents a secret key.
URI is a string that holds the TOTP URI.