Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit README.md #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ USAGE
=====
gototp is easy to use:

1. Generate a random secret to store for a user:
1. Clone the repository and build the package
```
git clone <repo-name>
cd <repo-name>
go build
```

2. Create another package and include this package in your project

3. Generate a random secret to store for a user:
````
// Do this somewhere early, and only once
rnd := rand.New(rand.NewSource(time.Now().Unix())
Expand All @@ -18,24 +27,26 @@ gototp is easy to use:
secret := gototp.RandomSecret(10, rand.New(rand.NewSource(time.Now().Unix())))
````

2. Create the OTP object:
4. Create the OTP object:
````
// Create the OTP
otp, err := gototp.New(secret)
if nil!=err {
panic(err)
}
````
3. Find the current TOTP code:

5. 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

6. 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)
````
````