本文整理汇总了Python中Crypto.Cipher.CAST.new方法的典型用法代码示例。如果您正苦于以下问题:Python CAST.new方法的具体用法?Python CAST.new怎么用?Python CAST.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto.Cipher.CAST
的用法示例。
在下文中一共展示了CAST.new方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_iv
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def setup_iv(self, iv=None):
self.iv = os.urandom(self.IV_LENGTH) if iv is None else iv
randkey = hmac.new(self.iv, self.key, hashlib.sha1).digest()
blocks_needed = (self.KEY_LENGTH + len(randkey) - 1) // len(randkey)
okm = bytearray()
output_block = b''
for counter in range(blocks_needed):
output_block = hmac.new(randkey, output_block + b'ss-subkey' + bytes([counter+1]), hashlib.sha1).digest()
okm.extend(output_block)
self.key = bytes(okm[:self.KEY_LENGTH])
self._nonce = 0
self._buffer = bytearray()
self._declen = None
self.setup()
示例2: setup
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def setup(self):
from Crypto.Cipher import ARC4
self.cipher = ARC4.new(self.key)
示例3: aes_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def aes_encrypt_transform(data, key, mode, iv):
aes = AES.new(key, mode, iv)
return aes.encrypt(data)
示例4: aes_decrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def aes_decrypt_transform(data, key, mode, iv):
aes = AES.new(key, mode, iv)
return aes.decrypt(data)
示例5: blowfish_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def blowfish_encrypt_transform(data, key, mode, iv):
blowfish = Blowfish.new(key, mode, iv)
return blowfish.encrypt(data)
示例6: blowfish_decrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def blowfish_decrypt_transform(data, key, mode, iv):
blowfish = Blowfish.new(key, mode, iv)
return blowfish.decrypt(data)
示例7: cast_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def cast_encrypt_transform(data, key, mode, iv):
cast = CAST.new(key, mode, iv)
return cast.encrypt(data)
示例8: des_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def des_encrypt_transform(data, key, mode, iv):
des = DES.new(key, mode, iv)
return des.encrypt(data)
示例9: des_decrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def des_decrypt_transform(data, key, mode, iv):
des = DES.new(key, mode, iv)
return des.decrypt(data)
示例10: des3_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def des3_encrypt_transform(data, key, mode, iv):
des = DES3.new(key, mode, iv)
return des.encrypt(data)
示例11: des3_decrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def des3_decrypt_transform(data, key, mode, iv):
des = DES3.new(key, mode, iv)
return des.decrypt(data)
示例12: rc2_encrypt_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def rc2_encrypt_transform(data, key, mode, iv):
arc2 = ARC2.new(key, mode, iv)
return arc2.encrypt(data)
示例13: rc4_transform
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def rc4_transform(data, key):
arc4 = ARC4.new(key)
return arc4.encrypt(data)
示例14: runTest
# 需要导入模块: from Crypto.Cipher import CAST [as 别名]
# 或者: from Crypto.Cipher.CAST import new [as 别名]
def runTest(self):
self.assertRaises(ValueError, CAST.new, bchr(0) * 4, CAST.MODE_ECB)
self.assertRaises(ValueError, CAST.new, bchr(0) * 17, CAST.MODE_ECB)