Python Forum

Full Version: UnicodeDecodeError:
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working on a password cracking tool.
The process of working:
->The user will give the md5 hash as input.
->The program then goes through a given file containing a wordlist, it searches for the correct match
for the md5 hash given.
->If the correct match is found, it returns the word(password), else it returns
"Password is not in the list".

The python code is given below:
import hashlib

flag = 0

pass_hash = input("Enter md5 hash: ")

wordlist = input("File name: ")

try:
    pass_file = open(wordlist, "r")
except:
    print("No file found")
    quit()

for word in pass_file:

    enc_wrd = word.encode('utf-8')
    digest = hashlib.md5(enc_wrd.strip()).hexdigest()

    if digest == pass_hash:
        print("Password found")
        print("Password: ",word)
        flag = 1
        break

if flag == 0:
    print("Password is not in the list")
This the Error I'm getting:
Error:
Traceback (most recent call last): File "/Users/admin/Desktop/Pythontests/passwordcracker/passcrack.py", line 15, in <module> for word in pass_file: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 5884: invalid continuation byte
I need a solution to this error.
Any help would be appreciated.
Thank You.