Class: ROTP::TOTP
Instance Attribute Summary (collapse)
-
- (Object) interval
readonly
Returns the value of attribute interval.
Instance Method Summary (collapse)
- - (Object) at(time)
-
- (TOTP) initialize(s, options = {})
constructor
A new instance of TOTP.
- - (Object) now
-
- (String) provisioning_uri(name)
Returns the provisioning URI for the OTP This can then be encoded in a QR Code and used to provision the Google Authenticator app.
Methods inherited from OTP
#byte_secret, #generate_otp, #int_to_bytestring
Constructor Details
- (TOTP) initialize(s, options = {})
A new instance of TOTP
6 7 8 9 |
# File 'lib/rotp/totp.rb', line 6 def initialize(s, = {}) @interval = [:interval] || 30 super end |
Instance Attribute Details
- (Object) interval (readonly)
Returns the value of attribute interval
4 5 6 |
# File 'lib/rotp/totp.rb', line 4 def interval @interval end |
Instance Method Details
- (Object) at(time)
11 12 13 14 15 16 |
# File 'lib/rotp/totp.rb', line 11 def at(time) unless time.class == Time time = Time.at(time.to_i) end generate_otp(timecode(time)) end |
- (Object) now
18 19 20 |
# File 'lib/rotp/totp.rb', line 18 def now generate_otp(timecode(Time.now)) end |
- (String) provisioning_uri(name)
Returns the provisioning URI for the OTP This can then be encoded in a QR Code and used to provision the Google Authenticator app
27 28 29 |
# File 'lib/rotp/totp.rb', line 27 def provisioning_uri(name) "otpauth://totp/#{URI.encode(name)}?secret=#{secret}" end |