Futtatás során hibaüzenettel leáll:
raise TypeError("Unicode-objects must be encoded before hashing")
TypeError: Unicode-objects must be encoded before hashing
Mit rontottam el?
import re
import bcrypt
raw = '/root/python_gyakorlas/bcrypt_hashes.txt'
raw_list = list()
with open(raw, 'r') as ll:
for item in ll:
pattern = re.compile(r'([^:]+):([a-zA-Z0-9]+)')
matches = pattern.finditer(item)
for match in matches:
raw_list.append(match.group(1, 2))
for item in raw_list:
password = item[1]
stored_hash = item[0]
# print(stored_hash)
# print(password)
if bcrypt.hashpw(password.encode('utf8'), stored_hash) == stored_hash:
print('Match')
else:
print ('It does not match')