Advertisement
Guest User

Untitled

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