https://github.com/zxdev/otp
one time password generation; RFC 4226 compliant
https://github.com/zxdev/otp
Last synced: 5 months ago
JSON representation
one time password generation; RFC 4226 compliant
- Host: GitHub
- URL: https://github.com/zxdev/otp
- Owner: zxdev
- License: mit
- Created: 2020-10-19T04:54:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-19T05:07:31.000Z (over 5 years ago)
- Last Synced: 2024-06-20T16:49:51.290Z (about 2 years ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# One Time Pass
This one time token generator is based off [RFC 4226](https://tools.ietf.org/html/rfc4226) and generates tokens based on a shared secret and the time interval.
## Variables
* Interval - default 30-seconds
* Entropy - number of bytes for Secret; default 20
## Functions
* Sizer - specify the number of digits to emit; default 6
* Secret - random secret generator; eg. AW6TJVTYMAYJXLWFW2WWJ6D3Q5B2AY25
* HOTPToken - generation requires a secret and an interval timeframe
* Token - is a HOTPToken with current Interval seed
* Tokens - is a HOTPToken with a bracketed last|now|next current Interval seed range
```golang
func main() {
secret := "secretsecretsecret"
fmt.Println(otp.Token(secret)) // 397657
fmt.Println(otp.Tokens(secret)) // [755604 397657 140422]
otp.Sizer(10)
fmt.Println(otp.Token(secret)) // 1545628642
fmt.Println(otp.Tokens(secret)) // [0511092633 1545628642 1383583942]
}
```