I want to compute an md5 hash not of a string, but of an entire data structure. I understand the mechanics of a way to do this (dispatch on the type of the value, canonical
bencode sorts dictionaries so:
import hashlib import bencode data = ['only', 'lists', [1,2,3], 'dictionaries', {'a':0,'b':1}, 'numbers', 47, 'strings'] data_md5 = hashlib.md5(bencode.bencode(data)).hexdigest() print data_md5
prints:
af1b88ca9fd8a3e828b40ed1b9a2cb20