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


Python Icedoll.encrypt方法代码示例

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


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

示例1: IcedollTestVec

# 需要导入模块: from crypto.cipher.icedoll import Icedoll [as 别名]
# 或者: from crypto.cipher.icedoll.Icedoll import encrypt [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: encrypt

# 需要导入模块: from crypto.cipher.icedoll import Icedoll [as 别名]
# 或者: from crypto.cipher.icedoll.Icedoll import encrypt [as 别名]
 def encrypt(self, plainText, more=None):
     """ """
     if not(self.hasIV):  # On first call to encrypt put in an IV
         plainText = self._makeIV() + plainText # add the 'IV'
         self.hasIV = 1
     if more == None:    # on last call to encrypt append integrity check
         plainText = plainText + self._makeIC()
     return Icedoll.encrypt(self, plainText, more=more)
开发者ID:herpoi,项目名称:opli-plugins,代码行数:10,代码来源:trolldoll.py

示例3: testDctEqPt

# 需要导入模块: from crypto.cipher.icedoll import Icedoll [as 别名]
# 或者: from crypto.cipher.icedoll.Icedoll import encrypt [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

示例4: testEncrcptDecryptMultiSizesPt

# 需要导入模块: from crypto.cipher.icedoll import Icedoll [as 别名]
# 或者: from crypto.cipher.icedoll.Icedoll import encrypt [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


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