blob: 1afd081227764f1da47e3a1a063c9a1a7e7f76d5 (
plain)
1
2
3
4
5
6
7
|
<tt>
Hello,<br><br>I&#39;m building an application in Python 2.7.1 using PyCrypto 2.3, and it&#39;s behaving badly with utf-8 and utf-16 strings. For example:<br><br>from Crypto.Cipher import AES<br>foo = AES.new(&#39;a1b2c3d4e5f6g7h8&#39;, AES.MODE_ECB)<br><br>
bar=u&#39;&#39;<br>for i in range(0,16):<br> bar+=unichr(255)<br># At this point, bar is<br># u&#39;\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff&#39;<br>baz=foo.encrypt(bar.encode(&#39;utf-8&#39;))<br><br>
blah=foo.decrypt(baz)<br># baz is now<br># &#39;\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf\xc3\xbf&#39;<br><br>How can I get encrypt and decrypt to use UTF gracefully?<br><br>
<br>Thank you,<br>Tom<br><br>
</tt>
|