-
-
Save plainas/f7fa9af721ac84c56c3727115243f207 to your computer and use it in GitHub Desktop.
hexstring to binstring
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 characters
def hex2binstr(bstr): | |
t = { | |
"0" : '0000', | |
"1" : '0001', | |
"2" : '0010', | |
"3" : '0011', | |
"4" : '0100', | |
"5" : '0101', | |
"6" : '0110', | |
"7" : '0111', | |
"8" : '1000', | |
"9" : '1001', | |
"a" : '1010', | |
"b" : '1011', | |
"c" : '1100', | |
"d" : '1101', | |
"e" : '1110', | |
"f" : '1111', | |
} | |
o = "" | |
for b in bstr: | |
o = o + t[b] | |
return o | |
print(hex2binstr("d4f3")) | |
print(hex2binstr("caf3")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment