Method: ROTP::OTP#initialize

Defined in:
lib/rotp/otp.rb

#initialize(s, options = {}) ⇒ OTP

Returns a new instance of OTP.

Parameters:

  • secret (String)

    in the form of base32

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • digits (Integer) — default: 6

    Number of integers in the OTP. Google Authenticate only supports 6 currently

  • digest (String) — default: sha1

    Digest used in the HMAC. Google Authenticate only supports ‘sha1’ currently

  • name (String)

    The name of the account for the OTP. Used in the provisioning URL

  • issuer (String)

    The issuer of the OTP. Used in the provisioning URL

  • provisioning_params (Hash) — default: {}

    Additional non-standard params you may want appended to the provisioning URI. Ex. ‘image: ’‘`



23
24
25
26
27
28
29
30
# File 'lib/rotp/otp.rb', line 23

def initialize(s, options = {})
  @digits = options[:digits] || DEFAULT_DIGITS
  @digest = options[:digest] || 'sha1'
  @name = options[:name]
  @issuer = options[:issuer]
  @provisioning_params = options[:provisioning_params] || {}
  @secret = s
end