本文整理汇总了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)