Message172506
I am getting inconsistent behavior when getting an md5 hexdigest on a json structure that's converted to a string.
Am I doing something wrong here?
import json
import hashlib
data = '''{"key1":"value1","key2":"value2"}'''
print(hashlib.md5(data.encode()).hexdigest())
jsonData = json.loads(data)
print(hashlib.md5(str(jsonData).encode()).hexdigest())
print(hashlib.md5(str(jsonData).encode()).hexdigest())
When I run this code everything seems just fine at a first glance. However, when it is run again I get different md5 checksums.
The first md5 checksum on the data string seems consistent every time.
The two last md5 checksums never seems to contradict each other during the same run, but between each run I often get different values.
Here are some outputs I'm getting:
ff45cc3835165307ef414c23ca2c6f67
423b2b4d92c0947e3d99d207c7c06175
423b2b4d92c0947e3d99d207c7c06175
ff45cc3835165307ef414c23ca2c6f67
101d66cd2878eacf47c618cea6862125
101d66cd2878eacf47c618cea6862125
ff45cc3835165307ef414c23ca2c6f67
423b2b4d92c0947e3d99d207c7c06175
423b2b4d92c0947e3d99d207c7c06175
ff45cc3835165307ef414c23ca2c6f67
101d66cd2878eacf47c618cea6862125
101d66cd2878eacf47c618cea6862125
(If it makes any difference, I'm running on Windows XP SP3) |
|
Date |
User |
Action |
Args |
2012-10-09 19:11:24 | poppe1219 | set | recipients:
+ poppe1219 |
2012-10-09 19:11:23 | poppe1219 | set | messageid: <1349809883.96.0.199738834001.issue16179@psf.upfronthosting.co.za> |
2012-10-09 19:11:23 | poppe1219 | link | issue16179 messages |
2012-10-09 19:11:23 | poppe1219 | create | |
|