当前位置: 首页>>代码示例>>Python>>正文


Python HOTP.generate_hmac方法代码示例

本文整理汇总了Python中authenticator.HOTP.generate_hmac方法的典型用法代码示例。如果您正苦于以下问题:Python HOTP.generate_hmac方法的具体用法?Python HOTP.generate_hmac怎么用?Python HOTP.generate_hmac使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在authenticator.HOTP的用法示例。


在下文中一共展示了HOTP.generate_hmac方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_generate_hmac_secret_not_byte_string

# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import generate_hmac [as 别名]
    def test_generate_hmac_secret_not_byte_string(self):
        """Test Otp.generate_hmac().

        Check that a counter that is other than a byte string.

        """
        cut = HOTP()
        # If the counter byte string is less than 8 bytes
        #
        with self.assertRaises(TypeError):
            cut.generate_hmac("1234567890", self.expected[1][0])
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py

示例2: test_generate_hmac_counter_not_byte_string

# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import generate_hmac [as 别名]
    def test_generate_hmac_counter_not_byte_string(self):
        """Test Otp.generate_hmac().

        Check that a counter that is other than a byte string.

        """
        cut = HOTP()
        # If the counter byte string is less than 8 bytes
        #
        with self.assertRaises(TypeError):
            cut.generate_hmac(self.secret, "1234")
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py

示例3: test_generate_hmac_bad_counter

# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import generate_hmac [as 别名]
    def test_generate_hmac_bad_counter(self):
        """Test Otp.generate_hmac().

        Check that a counter that is other than 8 bytes raises an error.

        """
        cut = HOTP()
        # If the counter byte string is less than 8 bytes
        #
        with self.assertRaises(ValueError):
            cut.generate_hmac(self.secret, bytes.fromhex("1234"))
        # If the counter byte string is more than 8 bytes
        #
        with self.assertRaises(ValueError):
            cut.generate_hmac(
                self.secret, bytes.fromhex("12345678901234567890"))
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:18,代码来源:test_hotp.py

示例4: test_generate_hmac

# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import generate_hmac [as 别名]
    def test_generate_hmac(self):
        """Test Otp.generate_hmac().

        Check that the RFC4226 test cases work for generate_hmac().

        """
        cut = HOTP()
        for i in range(0, 10):
            hmac = cut.generate_hmac(self.secret, self.expected[i][0])
            self.assertEqual(self.expected[i][1], hmac)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例5: test_hmac_from_counter

# 需要导入模块: from authenticator import HOTP [as 别名]
# 或者: from authenticator.HOTP import generate_hmac [as 别名]
    def test_hmac_from_counter(self):
        """Test Otp.generate_hmac().

        Check that expected HMAC-SHA-1 digest values are produced.

        """
        cut = HOTP()
        for i in range(0, 10):
            counter = cut.num_to_counter(i)
            actual_hmac = cut.generate_hmac(self.secret, counter)
            self.assertEqual(self.expected[i][1], actual_hmac)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py


注:本文中的authenticator.HOTP.generate_hmac方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。