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


Python Icedoll.decrypt方法代碼示例

本文整理匯總了Python中crypto.cipher.icedoll.Icedoll.decrypt方法的典型用法代碼示例。如果您正苦於以下問題:Python Icedoll.decrypt方法的具體用法?Python Icedoll.decrypt怎麽用?Python Icedoll.decrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在crypto.cipher.icedoll.Icedoll的用法示例。


在下文中一共展示了Icedoll.decrypt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: IcedollTestVec

# 需要導入模塊: from crypto.cipher.icedoll import Icedoll [as 別名]
# 或者: from crypto.cipher.icedoll.Icedoll import decrypt [as 別名]
 def IcedollTestVec(i, key, pt, ct):
     """ Run single AES test vector with any legal blockSize
         and any legal key size. """
     bkey, plainText, cipherText = a2b_hex(key), a2b_hex(pt), a2b_hex(ct)
     kSize = len(bkey)
     bSize = len(cipherText) # set block size to length of block
     alg = Icedoll(bkey, keySize=kSize, blockSize=bSize, padding=noPadding())
     cct = alg.encrypt(plainText)
     print 'pt    =',b2a_p(plainText)
     print 'ct    =',b2a_p(cct)
     dcct = alg.decrypt(cct)
     #print '_dcct',b2a_p(dcct)
     self.assertEqual( dcct, plainText )
     self.assertEqual( alg.encrypt(plainText),  cipherText )
     self.assertEqual( alg.decrypt(cipherText), plainText )
開發者ID:TerryLo,項目名稱:onchipsdk-1,代碼行數:17,代碼來源:icedoll_test.py

示例2: testDctEqPt

# 需要導入模塊: from crypto.cipher.icedoll import Icedoll [as 別名]
# 或者: from crypto.cipher.icedoll.Icedoll import decrypt [as 別名]
    def testDctEqPt(self):
        """ test of plaintext = decrypt(encrypt(plaintext)) """
        alg = Icedoll( 16*chr(0), padding=noPadding())
        pt  = 16*4*'a'             # block aligned
        ct  = alg.encrypt(pt)
        print 'ct  = ',b2a_p(ct)
        dct = alg.decrypt(ct)
        print 'dct = ',b2a_p(dct)
        assert(pt == dct), 'pt != dct'

        alg = Icedoll( 16*chr(0))  # autoPad
        pt  = 17*4*'a'             # non-block aligned
        ct  = alg.encrypt(pt)
        print 'ct  = ',b2a_p(ct)
        dct = alg.decrypt(ct)
        print 'dct = ',b2a_p(dct)
        assert(pt == dct), 'pt != dct'
開發者ID:TerryLo,項目名稱:onchipsdk-1,代碼行數:19,代碼來源:icedoll_test.py

示例3: testEncrcptDecryptMultiSizesPt

# 需要導入模塊: from crypto.cipher.icedoll import Icedoll [as 別名]
# 或者: from crypto.cipher.icedoll.Icedoll import decrypt [as 別名]
 def testEncrcptDecryptMultiSizesPt(self):
     """ Encrypt decrypt multiple sizes """
     alg = Icedoll( 16*chr(0))
     for size in range(100):
         pt = size*'a'
         ct = alg.encrypt(pt)
         #print 'ct  = ',b2a_p(ct)
         dct = alg.decrypt(ct)
         #print 'dct = ',b2a_p(dct)
         assert(pt == dct), 'pt != dct'
開發者ID:TerryLo,項目名稱:onchipsdk-1,代碼行數:12,代碼來源:icedoll_test.py

示例4: decrypt

# 需要導入模塊: from crypto.cipher.icedoll import Icedoll [as 別名]
# 或者: from crypto.cipher.icedoll.Icedoll import decrypt [as 別名]
 def decrypt(self, cipherText, more=None):
     """ Decrypt cipher text, Icedoll automatically removes
         prepended random bits used as IV.
         Note - typically IV is directly used as the first
         cipher text.  Here the IV is prepended to the plaintext
         prior to encryption and removed on decryption.
     """
     plainText = Icedoll.decrypt(self, cipherText, more=more)
     if not(self.hasIV):  # on first call to decrypt remove IV
         plainText = plainText[self.ivSize:] # remove the IV
         self.hasIV = 1
     if more == None:    # on last call to encrypt append integrity check
         if not(self._verifyIC(plainText[-self.micSize:])) :
             raise IntegrityCheckError, 'Trolldoll MIC Failure, bad key or modified data'
         plainText = plainText[:-self.micSize]  # trim off the integrity check
     return plainText
開發者ID:herpoi,項目名稱:opli-plugins,代碼行數:18,代碼來源:trolldoll.py


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