forked from Qalander/BitcoinHunter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreate12randomWords.py
30 lines (25 loc) · 1.03 KB
/
Create12randomWords.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# take entire list of 2048 from BIP39_English as used by Bitcoin Wallet, open as a list []
def random_12_words():
lines = []
file = open("BIP39_English",'r')
for line in file :
lines.append(line)
file.close()
# Erase the previous Wordlist as w indicates a fresh page, then close it again
open('MyWordList.txt', 'w').close()
# Select 12 random words from the BIP39_English List #
import random
# now open the file for appending
wordfile = open('MyWordList.txt', 'a')
# loop and randomly select 12 words (also print them to the terminal)
RW=""
x = 0
while (x < 12): # run from 0 to 11 (ie 12 words)
RW = (random.choice(lines)); print(RW)
wordfile.write(RW)
x +=1
random_12_words() # call the above function.
# memory efficient way to strip \n from list variables, but as we are writing back a list we leave the \n and grey out this code
### for i,s in enumerate(lines):
### lines[i] = s.strip()
### print(lines)