本文整理汇总了Python中authenticator.HOTP.hash_from_hmac方法的典型用法代码示例。如果您正苦于以下问题:Python HOTP.hash_from_hmac方法的具体用法?Python HOTP.hash_from_hmac怎么用?Python HOTP.hash_from_hmac使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类authenticator.HOTP
的用法示例。
在下文中一共展示了HOTP.hash_from_hmac方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hash_from_hmac_not_20bytes
# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import hash_from_hmac [as 别名]
def test_hash_from_hmac_not_20bytes(self):
"""Test Otp.hash_from_hmac().
Check that HMAC length validation is performed.
"""
cut = HOTP()
hmac = bytes.fromhex("ff0102030405060708090a0b0c0d0e0f101112")
with self.assertRaises(ValueError):
cut.hash_from_hmac(hmac)
示例2: test_hash_from_hmac_not_byte_string
# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import hash_from_hmac [as 别名]
def test_hash_from_hmac_not_byte_string(self):
"""Test Otp.hash_from_hmac().
Check that HMAC type (byte string) validation is performed.
"""
cut = HOTP()
hmac = bytearray.fromhex("ff0102030405060708090a0b0c0d0e0f101112f0")
with self.assertRaises(TypeError):
cut.hash_from_hmac(hmac)
示例3: test_hash_from_hmac_clear_high_bit
# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import hash_from_hmac [as 别名]
def test_hash_from_hmac_clear_high_bit(self):
"""Test Otp.hash_from_hmac().
Check that the high order bit is cleared in the truncated hash.
"""
cut = HOTP()
hmac = bytes.fromhex("ff0102030405060708090a0b0c0d0e0f101112f0")
expected = bytes.fromhex("7f010203")
hash = cut.hash_from_hmac(hmac)
self.assertEqual(expected, hash)
示例4: test_hash_from_hmac
# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import hash_from_hmac [as 别名]
def test_hash_from_hmac(self):
"""Test Otp.hash_from_hmac().
Check that expected truncated hash values are produced.
"""
cut = HOTP()
for i in range(0, 10):
hash = cut.hash_from_hmac(self.expected[i][1])
self.assertEqual(self.expected[i][2], hash)
return