https://github.com/lstep/gototp
Go Time-Based One Time Password.
https://github.com/lstep/gototp
Last synced: 5 months ago
JSON representation
Go Time-Based One Time Password.
- Host: GitHub
- URL: https://github.com/lstep/gototp
- Owner: lstep
- License: other
- Fork: true (bcleenders/gototp)
- Created: 2015-11-30T08:53:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-16T10:21:46.000Z (over 8 years ago)
- Last Synced: 2025-04-01T16:57:07.602Z (about 1 year ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gototp
======
Go Time-Based One Time Password implemention of RFC6238 (http://tools.ietf.org/html/rfc6238)
Based on pyotp: https://github.com/nathforge/pyotp
USAGE
=====
gototp is easy to use:
1. Generate a random secret to store for a user:
````
// A secret length of 10 gives a 16 character secret key
secret := gototp.RandomSecret(10)
````
2. Create the OTP object:
````
// Create the OTP
otp, err := gototp.New(secret)
if nil!=err {
panic(err)
}
````
3. Find the current TOTP code:
````
code := otp.Now()
// Or find the previous code and the next code
previousCode := otp.FromNow(-1)
nextCode := otp.FromNow(1)
````
4. Generate a Google Charts URL for a QR Code of the Secret, with a label
````
// Google Charts URL to display a QR Code, of width (and height) 300px
url := otp.QRCodeGoogleChartsUrl("My Own TOTP", 300)
````