我正在使用Zend2 Crypt module加密数据。这是我的密码。在
$cipher = BlockCipher::factory('mcrypt', array(
'algorithm' => 'aes',
));
$cipher->setKey('mypassphrase');
$encrypted = $cipher->encrypt('Hey, I am the secret data');
很酷,效果很好!现在,我需要在Python中解密$encrypted
数据(嘿,我就是秘密数据)。在
我用pycrypto来做这个。在我的PHP环境之外解密数据的步骤是什么?在
^{pr2}$我需要指定一个IV
,因为Zend在默认情况下使用的是MODE\ucbc。如何在Python代码中指定它?在
以下是Zend2文档:
The output of the encryption is a string, encoded in Base64 (default), that contains the HMAC value, the IV vector, and the encrypted text. The encryption mode used is the CBC (with a random IV by default) and SHA256 as default hash algorithm of the HMAC. The Mcrypt adapter encrypts using the PKCS#7 padding mechanism by default. You can specify a different padding method using a special adapter for that (Zend\Crypt\Symmetric\Padding). The encryption and authentication keys used by the BlockCipher are generated with the PBKDF2 algorithm, used as key derivation function from the user’s key specified using the setKey() method.
有人能帮我修改Python代码来解密数据吗? 谢谢
我找到了一种解密Zend2加密的数据的方法。我的代码是:
任务成功!
相关问题 更多 >
编程相关推荐