Sha256: 555e1af02ab6f5b1f7efc9702421c2ddc25f873449e08a3fa1a86566c38f9020
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require "test/unit" require "otp" class TestTOTP < Test::Unit::TestCase def assert_totp(totp, time, pass) totp.time = time assert_equal(pass, totp.password) assert(totp.verify(pass)) assert(!totp.verify(pass.chop)) end def test_totp_sha1 seed = "12345678901234567890" totp = OTP::TOTP.new(OTP::Base32.encode(seed), "SHA1", 8) assert_totp(totp, 59, "94287082") assert_totp(totp, 1111111109, "07081804") assert_totp(totp, 1111111111, "14050471") assert_totp(totp, 1234567890, "89005924") assert_totp(totp, 2000000000, "69279037") assert_totp(totp, 20000000000, "65353130") end def test_totp_sha256 seed = "12345678901234567890123456789012" totp = OTP::TOTP.new(OTP::Base32.encode(seed), "SHA256", 8) assert_totp(totp, 59, "46119246") assert_totp(totp, 1111111109, "68084774") assert_totp(totp, 1111111111, "67062674") assert_totp(totp, 1234567890, "91819424") assert_totp(totp, 2000000000, "90698825") assert_totp(totp, 20000000000, "77737706") end def test_totp_sha512 seed = "1234567890123456789012345678901234567890123456789012345678901234" totp = OTP::TOTP.new(OTP::Base32.encode(seed), "SHA512", 8) assert_totp(totp, 59, "90693936") assert_totp(totp, 1111111109, "25091201") assert_totp(totp, 1111111111, "99943326") assert_totp(totp, 1234567890, "93441116") assert_totp(totp, 2000000000, "38618901") assert_totp(totp, 20000000000, "47863826") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
otp-0.0.4 | test/test_totp.rb |
otp-0.0.3 | test/test_totp.rb |