本文整理匯總了Python中authenticator.HOTP.code_from_hash方法的典型用法代碼示例。如果您正苦於以下問題:Python HOTP.code_from_hash方法的具體用法?Python HOTP.code_from_hash怎麽用?Python HOTP.code_from_hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類authenticator.HOTP
的用法示例。
在下文中一共展示了HOTP.code_from_hash方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_code_from_hash_with_alternate_lengths
# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import code_from_hash [as 別名]
def test_code_from_hash_with_alternate_lengths(self):
"""Test Otp.code_from_hash().
Try with alternate code lengths.
"""
cut = HOTP()
# code_length 1
#
should_be = ("4", "2", "2", "9", "4", "6", "2", "3", "1", "9")
for i in range(0, 10):
code = cut.code_from_hash(self.expected[i][2], 1)
self.assertEqual(should_be[i], code)
# code_length 9
#
should_be = (
"284755224",
"094287082",
"137359152",
"726969429",
"640338314",
"868254676",
"918287922",
"082162583",
"673399871",
"645520489")
for i in range(0, 10):
code = cut.code_from_hash(self.expected[i][2], 9)
self.assertEqual(should_be[i], code)
示例2: test_code_from_hash_wrong_length
# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import code_from_hash [as 別名]
def test_code_from_hash_wrong_length(self):
"""Test Otp.code_from_hash().
Check that the RFC4226 test cases work for code_from_hash()
"""
cut = HOTP()
with self.assertRaises(ValueError):
cut.code_from_hash(bytes.fromhex("abcdef"))
示例3: test_code_from_hash_bad_hash
# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import code_from_hash [as 別名]
def test_code_from_hash_bad_hash(self):
"""Test Otp.code_from_hash().
Check that the RFC4226 test cases work for code_from_hash()
"""
cut = HOTP()
with self.assertRaises(TypeError):
cut.code_from_hash("abc")
示例4: test_code_from_hash_long_code_length
# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import code_from_hash [as 別名]
def test_code_from_hash_long_code_length(self):
"""Test Otp.code_from_hash().
Check that the RFC4226 test cases work for code_from_hash()
"""
cut = HOTP()
with self.assertRaises(ValueError):
cut.code_from_hash(self.expected[0][2], 11)
示例5: test_code_from_hash
# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import code_from_hash [as 別名]
def test_code_from_hash(self):
"""Test Otp.code_from_hash().
Check that the RFC4226 test cases work for code_from_hash()
"""
cut = HOTP()
for i in range(0, 10):
code = cut.code_from_hash(self.expected[i][2])
self.assertEqual(self.expected[i][3], code)