本文整理匯總了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)