當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。