A simple Bencoder for Python based on BencodePy.
- The encoder handles the non-standard elements, such as
float
,None
, andbool
. - The dict encoder is fixed so that dicts are sorted lexically by key name, otherwise the bencode string differs between uses.
The author uses bhencode
to produce MD5 hashes of Python objects.
import bhencode
import hashlib
hashlib.md5(bhencode.encode(raw_data)).hexdigest()
The easiest way to install this library is using pip.
pip install https://github.com/landonb/bhencode/archive/master.zip