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


Python HOTP.generate_code_from_counter方法代码示例

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


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

示例1: test_generate_code_from_counter_code_length_not_numeric

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

        Check for appropriate exception to non-numeric code_length.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, self.expected[0][0], code_length="abc")
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例2: test_generate_code_from_counter_counter_bad

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

        Check for appropriate exception to invalid counter value.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, -1)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例3: test_generate_code_from_counter_code_length_wrong_type

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

        Check for appropriate exception to wrong code_length type.

        """
        cut = HOTP()
        with self.assertRaises(TypeError):
            cut.generate_code_from_counter(
                self.secret, self.expected[0][0], code_length=(6, 3))
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例4: test_generate_code_from_counter_counter_wrong_type

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

        Check for appropriate exception to wrong counter type.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, "abcdefgh")
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例5: test_generate_code_from_counter_secret_wrong_type

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

        Check for appropriate exception to wrong secret type.

        """
        cut = HOTP()
        with self.assertRaises(TypeError):
            cut.generate_code_from_counter(
                1.234, self.expected[0][0])
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:12,代码来源:test_hotp.py

示例6: test_generate_code_from_counter_secret_wrong_base32_length

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

        Check for appropriate exception to secret string that is invalid
        base32 encoding (too long, bad padding).

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQAAA", self.expected[0][0])
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py

示例7: test_generate_code_from_counter_secret_bad_base32

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

        Check for appropriate exception to secret string that is invalid
        base32 encoding.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                "GEZDGNBVGY1TQOJQGEZDGNBVGY1TQOJQ", self.expected[0][0])
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py

示例8: test_generate_code_from_counter_counter_long

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

        Check for appropriate exception to counter byte string that is
        too short.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, bytes.fromhex("010203040506070809"))
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:13,代码来源:test_hotp.py

示例9: test_generate_code_from_counter_code_length_out_of_range

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

        Check for appropriate exception to out-of-range code_length.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, self.expected[0][0], code_length="0")
        with self.assertRaises(ValueError):
            cut.generate_code_from_counter(
                self.secret, self.expected[0][0], code_length=11)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:15,代码来源:test_hotp.py

示例10: test_generate_code_from_counter_integer_b32_secret

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

        Check that the RFC4226 test cases work for generate_code_from_counter()
        when passed counter as an integer and secret as base32 string.

        """
        cut = HOTP()
        # test with counter as integer value and secret as base32 string
        #
        for i in range(0, 10):
            code_string = cut.generate_code_from_counter(self.secret_base32, i)
            self.assertEqual(self.expected[i][3], code_string)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:15,代码来源:test_hotp.py

示例11: test_generate_code_from_counter_byte_string

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

        Check that the RFC4226 test cases work for generate_code_from_counter()
        when passed counter as a byte string and secret as byte string.

        """
        cut = HOTP()
        # test with counter as byte string and secret as byte string.
        #
        for i in range(0, 10):
            code_string = cut.generate_code_from_counter(
                self.secret, self.expected[i][0])
            self.assertEqual(self.expected[i][3], code_string)
开发者ID:JeNeSuisPasDave,项目名称:authenticator,代码行数:16,代码来源:test_hotp.py


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