0

I am writing a program that will encrypt words from a list until the hash matches the one you are trying to decrypt.

The problem I am having is that when the hash is encrypted, it does not loose any of the whitespace characters and I get hashes like:

b'\x0by\x07\xb4\xe8\xd9\x90d\xaa\xd9\xe6\x1d\xfa\x92\xc2\xaf

and not 63eb1dea1692fc53800b20be983e9a8b

Is there any way I can get rid of all whitespaces before I encrypt?

This is my code:

import hashlib
def computeMD5hash(string):
    m = hashlib.md5()
    m.update(string.encode('utf-8'))
    md5string=m.digest()
    return md5string

wordlist = open('wordlist.txt', 'r')
words = wordlist.readlines()
words = [x.strip('\n') for x in words]
print("Searching...")
for i in words:
    for x in words:
        print(i+x)
        out = computeMD5hash(i+x)
        print(out)
        if out == '63eb1dea1692fc53800b20be983e9a8b':
            print(i+x)
            break

Edit: Sorry, it's not just whitespace, but there aren't supposed to be backslashes in the hash, and I feel like either the encoding is wrong or my method for encrypting is not correct. All I know is that the output is wrong, and I have checked it against multiple sources.

2
  • Where is the whitespace? Commented Mar 23, 2018 at 1:33
  • Sorry, it's not just whitespace, but there aren't supposed to be backslashes in the hash, and I feel like either the encoding is wrong or my method for encrypting is not correct. All I know is that the output is wrong, and I have checked it against multiple sources. Commented Mar 23, 2018 at 1:39

1 Answer 1

2
def computeMD5hash(string):
    m = hashlib.md5()
    m.update(string.encode('utf-8'))
    md5string=m.hexdigest() # use hexdigest instead
    return md5string
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.