Created
January 3, 2015 20:27
-
-
Save brianmhunt/09a82cbda559cfcc47dd to your computer and use it in GitHub Desktop.
Revisions
-
brianmhunt created this gist
Jan 3, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ """ Human UX strings mapping See http://stackoverflow.com/a/27459196 0 1 2 3 4 5 6 7 8 9 A B C D E F Hexadecimal H M N 3 4 P 6 7 R 9 T W C X Y F Replacement Y = U = V C = G X = K F = E """ import string trans_table = string.maketrans( "HMN34P67R9TWCGXKYUVFE", "0123456789ABCCDDEEEFF" ) def translate(str): """Normalize to an unambiguous Base16 string >>> translate("hmn34P67r9") '0123456789' >>> translate("WCGXKYUVFE") 'BCCDDEEEFF' """ return str.upper().translate(trans_table)