I am doing an advent of code problem and am trying to convert MD5 into hex, and I have no clue where to begin.
I tried looking on different websites, but I couldn't understand them. The stack overflow answers, similarly did not help.
What you need to do is to convert the secret
string into MD5 hash. For that, use the hashlib
library:
from hashlib import md5
secret = 'abcdef609043'
print(md5(secret.encode()).hexdigest())
Output:
000001dbbfa3a5c83a2d506429c7b00e
Brief explanation: You first need to get the bytes of the secret
string with the .encode
method, and then get the hexadecimal representation of the MD5 digest with .hexdigest()
.