Created
June 11, 2015 13:05
-
-
Save wizardofozzie/c9b8af7c0d9fa9553dbb to your computer and use it in GitHub Desktop.
bip39_to_entropy.py
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
In [109]: ML | |
Out[109]: | |
[u'wife', | |
u'olive', | |
u'club', | |
u'barely', | |
u'trap', | |
u'zero', | |
u'scare', | |
u'warrior', | |
u'garage', | |
u'finger', | |
u'lake', | |
u'cash'] | |
In [110]: ret = u" ".join([BIP39[int(x, 2)] for x in [bstr[i:i + 11] for i in range(0, len(bst | |
r), 11)]]) | |
In [111]: ret | |
Out[111]: u'wife olive club barely trap zero scare warrior garage finger lake cash' | |
In [112]: [WORDS['english'].index(w) for w in ret.split()] | |
Out[112]: [2007, 1233, 353, 148, 1850, 2045, 1538, 1978, 763, 695, 997, 282] | |
In [113]: map(lambda d: changebase(str(d), 10, 2, 11), [WORDS['english'].index(w) for w in ret | |
.split()]) | |
Out[113]: | |
['11111010111', | |
'10011010001', | |
'00101100001', | |
'00010010100', | |
'11100111010', | |
'11111111101', | |
'11000000010', | |
'11110111010', | |
'01011111011', | |
'01010110111', | |
'01111100101', | |
'00100011010'] | |
In [114]: ''.join(map(lambda d: changebase(str(d), 10, 2, 11), [WORDS['english'].index(w) for | |
w in ret.split()]))[:128] | |
Out[114]: '11111010111100110100010010110000100010010100111001110101111111110111000000010111101 | |
110100101111101101010110111011111001010010001' | |
In [115]: changebase(''.join(map(lambda d: changebase(str(d), 10, 2, 11), [WORDS['english'].in | |
dex(w) for w in ret.split()]))[:128], 2, 16) | |
Out[115]: 'faf344b0894e75ff7017ba5f6addf291' | |
In [116]: hexstr | |
Out[116]: '\xfa\xf3D\xb0\x89Nu\xffp\x17\xba_j\xdd\xf2\x91' | |
In [117]: %rep 115 | |
In [118]: pycp("""changebase(''.join(map(lambda d: changebase(str(d), 10, 2, 11), [WORDS['engl | |
ish'].index(w) for w in ret.split()]))[:128], 2, 16)""") | |
In [119]: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment