I am trying to create a login system for my project and I need to use hashing for the users password, I am unsure how to hash a variable name and convert it into bytes to give a hex result for the password.
tried using:
hash_object = hashlib.md5(b(password))
and:
hash_object = hashlib.md5((password))
Code:
import hashlib
user = {}
username = input("What is your username? ")
password = input("What is your password? ")
hash_object = hashlib.md5((password))
print(hash_object.hexdigest())
Error:
Traceback (most recent call last):
File "E:\loginsystem.py", line 8, in <module>
hash_object = hashlib.md5((password))
TypeError: Unicode-objects must be encoded before hashing