[Tutor] Help converting base32 to base16
Kent Johnson
kent37 at tds.net
Mon Jun 18 18:30:55 CEST 2007
cms cms wrote:
> Hello all,
>
> Newbie here trying to find a module that I can use to convert a number of
> strings (sha1 values) from base32 to base16 (hex), and vice versa. I've
> searched this list for similar questions, the Global Module Index, the
> Vaults of Parnassus, as well as the obvious (Google); however , I cannot
> seem to find anything on point. While I'm sure the solution will be obvious,
> it currently escapes me.
The int() function takes a second argument of the base, so it can
convert from base 16 or base 32 to integers. The hex() function converts
from integer to base 16 but there is no equivalent built-in for base 32.
This cookbook recipe will convert in both directions:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286
Kent
More information about the Tutor
mailing list