You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
308 B
12 lines
308 B
9 years ago
|
# Helper class to simulate a user generating TOTP codes from a secret key
|
||
|
class TotpHelper
|
||
|
def initialize(secret_key, otp_length)
|
||
|
@secret_key = secret_key
|
||
|
@otp_length = otp_length
|
||
|
end
|
||
|
|
||
|
def totp_code(time = Time.now)
|
||
|
ROTP::TOTP.new(@secret_key, digits: @otp_length).at(time, true)
|
||
|
end
|
||
|
end
|