Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from binascii import crc32
  2. from words import word_list
  3.  
  4. def get_checksum(phrase):
  5.     """Given a mnemonic word string, return a string of the computed checksum.
  6.      :rtype: str
  7.    """
  8.     wstr = "".join(word[:3] for word in phrase)
  9.     wstr = bytearray(wstr.encode('utf-8'))
  10.     z = ((crc32(wstr) & 0xffffffff) ^ 0xffffffff ) >> 0
  11.     z2 = ((z ^ 0xffffffff) >> 0) % len(phrase)
  12.     return phrase_split[z2]
  13.    
  14. def brute_force(phrase,checksum):
  15.     phrase_split = phrase.split(" ")
  16.     for word in words.word_list:
  17.         for i in range(24):
  18.             trial = phrase[:i] + [word] + phrase[i:]
  19.             if checksum == get_checksum(trial):
  20.                 print(" ".join(trial.append(checksum)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement