當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。