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


Python CAST.new方法代码示例

本文整理汇总了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() 
开发者ID:qwj,项目名称:python-proxy,代码行数:16,代码来源:cipher.py

示例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) 
开发者ID:qwj,项目名称:python-proxy,代码行数:5,代码来源:cipher.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:Vector35,项目名称:deprecated-binaryninja-python,代码行数:5,代码来源:Transform.py

示例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) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:5,代码来源:test_CAST.py


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