A fast and correct bencode serialize/deserialize library


Keywords
bencode, bit-torrent, bittorrent, deserialize, p2p, serialize
License
MIT
Install
pip install bencode2==0.0.17

Documentation

A fast and correct bencode serialize/deserialize library

PyPI tests PyPI - Python Version Codecov branch

This library is compiled with mypy on cpython, and pure python on pypy.

install

pip install bencode2

basic usage

import bencode2


assert bencode2.bdecode(b"d4:spaml1:a1:bee") == {b"spam": [b"a", b"b"]}

# if you want to decode dict with str keys
assert bencode2.bdecode(b"d4:spaml1:a1:bee", str_key=True) == {"spam": [b"a", b"b"]}

assert bencode2.bencode({'hello': 'world'}) == b'd5:hello5:worlde'