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


Python OCRA.create_data_input方法代码示例

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


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

示例1: test_08_create_data_input

# 需要导入模块: from privacyidea.lib.tokens.ocra import OCRA [as 别名]
# 或者: from privacyidea.lib.tokens.ocra.OCRA import create_data_input [as 别名]
    def test_08_create_data_input(self):
        # The ocrasuite is stored as a unicode in the webui. As it is used for
        # the OCRA datainput, it must be internally converted to a string.
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10"
        question = "1344454126"
        ocra_object = OCRA(ocrasuite, binascii.unhexlify(KEY20))
        r = ocra_object.create_data_input(question)

        # create data_input with missing counter
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:C-QN10"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)

        # create data_input with missing PIN
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10-PSHA1"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)

        # create data_input with missing Timesteps
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10-T1M"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)

        ocrasuite = u"OCRA-1:HOTP-SHA1-8:QH40"
        dTAN = "83507112  ~320,00~1399458665_G6HNVF"
        question = binascii.hexlify(hashlib.sha1(dTAN).digest())
        ocra_object = OCRA(ocrasuite, binascii.unhexlify(KEY20))
        r = ocra_object.create_data_input(question)
        self.assertEqual(len(r), 128 + len(ocrasuite) + 1)
开发者ID:hrz-unimr,项目名称:privacyidea,代码行数:31,代码来源:test_lib_tokens_tiqr.py

示例2: test_08_create_data_input

# 需要导入模块: from privacyidea.lib.tokens.ocra import OCRA [as 别名]
# 或者: from privacyidea.lib.tokens.ocra.OCRA import create_data_input [as 别名]
    def test_08_create_data_input(self):
        # The ocrasuite is stored as a unicode in the webui. As it is used for
        # the OCRA datainput, it must be internally converted to a string.
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10"
        question = "1344454126"
        ocra_object = OCRA(ocrasuite, binascii.unhexlify(KEY20))
        r = ocra_object.create_data_input(question)

        # create data_input with missing counter
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:C-QN10"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)

        # create data_input with missing PIN
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10-PSHA1"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)

        # create data_input with missing Timesteps
        ocrasuite = u"OCRA-1:HOTP-SHA1-6:QN10-T1M"
        ocra_object=OCRA(ocrasuite, binascii.unhexlify(KEY20))
        self.assertRaises(Exception, ocra_object.create_data_input, question)
开发者ID:dhoffend,项目名称:privacyidea,代码行数:24,代码来源:test_lib_tokens_tiqr.py


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