Created
December 7, 2011 21:51
-
-
Save Ramblurr/1444853 to your computer and use it in GitHub Desktop.
Converts a base32 encoded string to a base 16 string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# Converts a base32 encoded string to a base 16 string | |
# requires numconv package | |
import numconv | |
import re | |
google_key = raw_input("Google key: ") | |
clean_32 = re.sub(r'\s', '', google_key).upper() | |
base_32_int = numconv.NumConv(32, numconv.BASE32).str2int( clean_32 ) | |
base_16_str = numconv.NumConv(16).int2str( base_32_int ) | |
key = base_16_str | |
def pad_right(string, length, padding=' '): | |
if len(string) < length: | |
return string + padding[0] * (length - len(string)) | |
else: | |
return string | |
print "Hex: " + pad_right(key, 40, '0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment