擅长:python、mysql、java
<p>免责声明:我对Python非常陌生,但请尝试一下:<br/><br/>
试着换衣服</p>
<pre><code>key = key[:16]
</code></pre>
<p>到</p>
^{pr2}$
<p>这将给你一个24字节的密钥,我想应该可以用。在</p>
<p>DCP允许任何长度的密钥,而Crypto则坚持密钥为16、24或32字节。默认情况下,DCP将使用SHA1生成密钥,该密钥的长度为20字节。在此基础上,DCP使用keylength<;=24的逻辑,而不是keylength<;=16的逻辑,而keylength<;=16的逻辑就是key[:16]所起的作用。在</p>
<p>另外,不知道这是否只是一个打字错误,但尝试改变AES模式</p>
<pre><code>cipher = AES.new(key, AES.MODE_CFB, iv)
</code></pre>
<p>到</p>
<pre><code>cipher = AES.new(key, AES.MODE_CBC, iv)
</code></pre>
<p>这将对您的输入进行解密。但是,您需要考虑原始源文本的填充,因为DCP不会填充(我认为),但是加密需要16的倍数才能解密。在</p>