Those worked. Thanks.<br><br><div class="gmail_quote">On Mon, May 16, 2011 at 3:54 PM, Lorenz Quack <span dir="ltr"><<a href="mailto:don@amberfisharts.com">don@amberfisharts.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Thomas,<br>
<br>
what about either:<br>
<br>
blah=foo.decrypt(baz).decode("utf-8")<br>
<br>
or<br>
<br>
blah=unicode(foo.decrypt(baz), "utf-8")<br>
<br>
cheers,<br>
Lorenz<br>
<div><div></div><div class="h5"><br>
On 05/16/2011 09:18 PM, Thomas Knox wrote:<br>
> Hello,<br>
><br>
> I'm building an application in Python 2.7.1 using PyCrypto 2.3, and it's behaving badly with utf-8 and utf-16 strings.<br>
> For example:<br>
><br>
> from Crypto.Cipher import AES<br>
> foo = AES.new('a1b2c3d4e5f6g7h8', AES.MODE_ECB)<br>
> bar=u''<br>
> for i in range(0,16):<br>
> bar+=unichr(255)<br>
> # At this point, bar is<br>
> # u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'<br>
> baz=foo.encrypt(bar.encode('utf-8'))<br>
> blah=foo.decrypt(baz)<br>
> # baz is now<br>
> #<br>
> '\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'<br>
><br>
> How can I get encrypt and decrypt to use UTF gracefully?<br>
><br>
> Thank you,<br>
> Tom<br>
><br>
><br>
<br>
</div></div>_______________________________________________<br>
pycrypto mailing list<br>
<a href="mailto:pycrypto@lists.dlitz.net">pycrypto@lists.dlitz.net</a><br>
<a href="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto" target="_blank">http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto</a><br>
</blockquote></div><br>