-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
25 lines (18 loc) · 968 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
A simple class to work with Google Authenticator from ruby. Can
generate a secret key along with qrcode url/image and generate
one time passwords for a secret key.
See Also: http://code.google.com/p/google-authenticator/
Generating the Secret Key
----------------------------------------------------
ga = GoogleAuthenticator.new
ga.secret_key # => "NINWS2QUIQD2LA2Z"
ga.qrcode_url('user@domain.com') # => "otpauth://totp/user@domain.com?secret=NINWS2QUIQD2LA2Z"
ga.qrcode_image_url('user@domain.com') # => "https://chart.googleapis.com/chart?chs=350x350&cht=qr&choe=UTF-8&chl=otpauth://totp/user@domain.com?secret=NINWS2QUIQD2LA2Z"
# Verifying a Key
----------------------------------------------------
ga = GoogleAuthenticator.new('NINWS2QUIQD2LA2Z')
ga.key_valid?(key) # => true or false
# Generate Your Own Keys
---------------------------------------------------
ga = GoogleAuthenticator.new('NINWS2QUIQD2LA2Z')
ga.get_keys # => [Previous, Current, Next]