New submission from Robin Åsén: 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) ---------- components: Interpreter Core messages: 172506 nosy: poppe1219 priority: normal severity: normal status: open title: hashlib.md5 / json inconsistency type: behavior versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16179> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com