當前位置: 首頁>>代碼示例>>Python>>正文


Python HOTP.hash_from_hmac方法代碼示例

本文整理匯總了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)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:12,代碼來源:test_hotp.py

示例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)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:12,代碼來源:test_hotp.py

示例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)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:13,代碼來源:test_hotp.py

示例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
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:13,代碼來源:test_hotp.py


注:本文中的authenticator.HOTP.hash_from_hmac方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。