forked from trezor/python-mnemonic
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rejigged the trezor sample mnemonic tools into a little Tkinter gui f…
…or taking bip39 seed words and reordering them so they're valid. Removed tests, readme, setup for now.
- Loading branch information
1 parent
f9f7720
commit 6aaa6f4
Showing
17 changed files
with
63 additions
and
2,613 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from Tkinter import * | ||
import itertools | ||
import os | ||
import binascii | ||
import mnemonic | ||
import random | ||
|
||
|
||
class App: | ||
def __init__(self, master): | ||
frame = Frame(master) | ||
frame.pack() | ||
self.inputa_label = Label(frame, text="Input a list of bip39 words with spaces between them:") | ||
self.inputa_label.pack() | ||
self.entry_seed = Entry(frame, bd=3, width=80) | ||
self.entry_seed.pack() | ||
self.button_shuffle = Button(frame, text="Shuffle words", command=self.mix_words) | ||
self.button_shuffle.pack() | ||
self.result_description = Label(frame, text="In this order, your words are a valid bip39 seed:") | ||
self.result_description.pack() | ||
self.result_label = Label(frame, text="") | ||
self.result_label.pack() | ||
self.slogan = Button(frame, | ||
text="Force valid bip39 order", | ||
command=self.main_validate) | ||
self.slogan.pack() | ||
self.button_quit = Button(frame, | ||
text="QUIT", fg="red", | ||
command=frame.quit) | ||
|
||
self.button_quit.pack() | ||
|
||
def main_validate(self): | ||
"""Checks for a valid bip39 seed from the given list of words.""" | ||
self.result_label['text'] = '' | ||
seed_input = [] | ||
seed_input = self.entry_seed.get().split() | ||
m = mnemonic.Mnemonic('english') | ||
for subset in itertools.permutations(seed_input, len(seed_input)): | ||
if len(subset) == len(seed_input): | ||
if m.check(' '.join(subset)): | ||
if subset != seed_input: | ||
self.result_label['text'] = ' '.join(subset) | ||
else: | ||
self.result_label['text'] = "There was a problem with the words you gave, maybe they are not on the bip39 word list or the number of words does not work." | ||
break # found a valid one, stop looking. | ||
|
||
def mix_words(self): | ||
"""Shuffles the words in the entry field.""" | ||
seed_input = [] | ||
seed_input = self.entry_seed.get().split() | ||
# print(seed_input) | ||
shuffled = random.sample(seed_input, len(seed_input)) | ||
# print(shuffled) | ||
self.entry_seed.delete(0, END) | ||
self.entry_seed.insert(0, " ".join(shuffled)) | ||
|
||
|
||
root = Tk() | ||
root.title("Force39") | ||
app = App(root) | ||
root.mainloop() |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.