[pycrypto] PyCrypto 2.3 and unicode

Thomas Knox knoxth at gmail.com
Mon May 16 13:53:16 CST 2011


Those worked. Thanks.

On Mon, May 16, 2011 at 3:54 PM, Lorenz Quack <don at amberfisharts.com> wrote:

> Hi Thomas,
>
> what about either:
>
> blah=foo.decrypt(baz).decode("utf-8")
>
> or
>
> blah=unicode(foo.decrypt(baz), "utf-8")
>
> cheers,
> Lorenz
>
> On 05/16/2011 09:18 PM, Thomas Knox wrote:
> > Hello,
> >
> > 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.
> > For example:
> >
> > from Crypto.Cipher import AES
> > foo = AES.new('a1b2c3d4e5f6g7h8', AES.MODE_ECB)
> > bar=u''
> > for i in range(0,16):
> >      bar+=unichr(255)
> > # At this point, bar is
> > # u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
> > baz=foo.encrypt(bar.encode('utf-8'))
> > blah=foo.decrypt(baz)
> > # baz is now
> > #
> >
> '\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'
> >
> > How can I get encrypt and decrypt to use UTF gracefully?
> >
> > Thank you,
> > Tom
> >
> >
>
> _______________________________________________
> pycrypto mailing list
> pycrypto at lists.dlitz.net
> http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.dlitz.net/pipermail/pycrypto/attachments/20110516/32f2687e/attachment.htm 


More information about the pycrypto mailing list