This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author poppe1219
Recipients poppe1219
Date 2012-10-09.19:11:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349809883.96.0.199738834001.issue16179@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2012-10-09 19:11:24poppe1219setrecipients: + poppe1219
2012-10-09 19:11:23poppe1219setmessageid: <1349809883.96.0.199738834001.issue16179@psf.upfronthosting.co.za>
2012-10-09 19:11:23poppe1219linkissue16179 messages
2012-10-09 19:11:23poppe1219create