print question - character representation

Michael Foord fuzzyman at gmail.com
Fri Aug 27 12:49:49 CEST 2004


Ajay <abra9823 at mail.usyd.edu.au> wrote in message news:<mailman.2504.1093588872.5135.python-list at python.org>...
> hi!
> 
> i am calculating a digest of some data (using hmac) and printing it to a
> cookie. the problem is the hash may contain special characters. when these
> are printed they get converted to \<number> representation.
> later when i receive the cookie i recalculate the hmac and do a comparison
> which returns false because of the conversion when writing to a cookie
> 
> q - how do i stop the conversion from happening? if i cant then how can i
> convert the hmac i recalculate on receiving the cookie to the same
> representation as the one printed
> 
> thanks
> 
> cheers
> 
> 
> 

One way is to use a binary to ascii conversion - like the binascii module.

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list