Documentation ¶
Overview ¶
Package otp
TOTP: https://en.wikipedia.org/wiki/One-time_password
https://datatracker.ietf.org/doc/html/rfc6238
HOTP: https://en.wikipedia.org/wiki/HMAC-based_one-time_password
https://datatracker.ietf.org/doc/html/rfc4226
Copyright 2021 Inanzzz.com
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type OTP ¶
type OTP struct {
// contains filtered or unexported fields
}
func NewHOTP ¶
NewHOTP return new otp that's use HMAC-based One-Time Password. Good when sending otp via sms or email. Not recommended yet for this app since this app does not support sending any email yet.
func NewTOTP ¶
NewTOTP return new otp that's use Time-based One-Time Password. Good when used with mobile apps such as Microsoft Authenticator or Google Authenticator etc.
func (*OTP) CreateHOTPCode ¶
CreateHOTPCode creates a new HOTP with a specific counter. This method is ideal if you are planning to send manually created code via email, SMS etc. The user should not be present a QR code for this option otherwise there is a high possibility that the client and server counters will be out of sync, unless the user will be forced to rescan a newly generated QR with up-to-date counter value.
func (*OTP) CreateURI ¶
CreateURI builds the authentication URI which is used to create a QR code. If the counter is set to 0, the algorithm is assumed to be TOTP, otherwise HOTP. REF: https://github.com/google/google-authenticator/wiki/Key-Uri-Format