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

</tt>