I need to write a md5 hash in python from php and have been suck trying to make the dates give the right md5 hash. Both languages print the exact same date but if that date is hashed the hash is different.
** md5 hash needs to match the original php hash (changes need to be made to python not php)
md5.py
import hashlib, datetime
timestamp = datetime.datetime.now() - datetime.timedelta(hours=6)
timestamp1 = timestamp.strftime("%Y-%m-%d %H:%M:%S")
print(timestamp1)
md5_digest = hashlib.md5(timestamp1.encode()).hexdigest()
print (md5_digest)
md5.php
<?php
$strDatetime = date("Y-m-d H:i:s");
function get_md5_hash($strDatetime) {
return md5(strtotime($strDatetime));
}
print("$strDatetime");
print get_md5_hash("$strDatetime", "$strAuthWindow", "$strSalt");
?>
This is the result I get:
2018-04-18 13:24:01 36bae8f24429309f147f3bd6d8a1e0c9
2018-04-18 13:24:01 0eab3b000e3d831a57f9e7b77f136900