本文整理匯總了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