lib/rotp/totp.rb in rotp-1.1.0 vs lib/rotp/totp.rb in rotp-1.2.0
- old
+ new
@@ -24,9 +24,15 @@
# @return [Integer] the OTP as an integer
def now
generate_otp(timecode(Time.now))
end
+ # Verifies the OTP passed in against the current time OTP
+ # @param [String/Integer] otp the OTP to check against
+ def verify(otp, time = Time.now)
+ otp == self.at(time)
+ end
+
# Returns the provisioning URI for the OTP
# This can then be encoded in a QR Code and used
# to provision the Google Authenticator app
# @param [String] name of the account
# @return [String] provisioning uri