Python version of binascii.b2a_hex (binary to hex conversion)?
Graham Guttocks
graham_guttocks at yahoo.co.nz
Fri Apr 27 15:17:19 EDT 2001
Greetings,
I need to support Python < 2.0 with one of my apps that uses
binascii.b2a_hex and binascii.a2b_hex to convert between binary data
and it's hexadecimal representation. Since these functions aren't
available in earlier Python versions, I need to implement them myself.
For binary --> hex, I've found the following in the list archives:
def hexlify(b):
return "%02x"*len(b) % tuple(map(ord, b))
I couldn't find the reverse (hexadecimal string --> binary data).
Does anyone have such a function handy?
Regards,
Graham
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
More information about the Python-list
mailing list