I want to compare a hash of my password to a hash of what the user typed in, with (str)(hashlib.md5(pw.encode('utf-8')).hexdigest())
.
The hash of the password is b'¥_ÆMÐ1;2±*öªÝ='
. However, when I run the above code, I get b'xa5x83_xc6x85Mxd01;2xb1*xf6xaaxdd='
.
For this reason, I can’t compare these two strings. I’m looking for a function that can convert b'xa5x83_xc6x85Mxd01;2xb1*xf6xaaxdd='
to b'¥_ÆMÐ1;2±*öªÝ='
logically (each of the escape codes to its Unicode counterpart).
(The hash is of “lenny” if it helps. Here is a link to my code.)
Advertisement
Answer
Use .digest()
instead of .hexdigest()
if you want the raw bytes from the hash context.
edit, line 14 from your pastebin should be:
if hashlib.md5(lol.encode('utf-8')).digest() == b'xa5x83_xc6x85Mxd01;2xb1*xf6xaaxdd=':