Simple bencoding decode/encode library
Project description
Simple bencoding decode/encode library 🔖
Install
pip install bencodingpy
Usage
Decode
>>> from bencodingpy import decode
>>> decode(b'4:spam')
'spam'
>>> decode(b'i1234e')
1234
>>> decode(b'l4:spam4:eggse')
['spam', 'eggs']
>>> decode(b'd4:spaml1:a1:bee ')
{'spam': ['a', 'b']}
>>> with open('debian-12.5.0-amd64-netinst.iso.torrent', 'rb') as file:
... decoded_torrent = decode(file)
... print(decoded_torrent['announce'])
...
http://bttracker.debian.org:6969/announce
Encode
>>> from bencodingpy import encode
>>> encode('spam')
b'4:spam'
>>> encode(1234)
b'i1234e'
>>> encode(['spam', 'eggs'])
b'l4:spam4:eggse'
>>> encode({'spam': ['a', 'b']})
b'd4:spaml1:a1:bee'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bencodingpy-1.0.0.dev2.tar.gz
(69.3 kB
view hashes)
Built Distribution
Close
Hashes for bencodingpy-1.0.0.dev2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 096f84550cf73bdceef5e0dddc6f1769cc3dce09ce4af655ee640458dbdad1b6 |
|
MD5 | a8c633b3a5fceed14938c1687c7eb25c |
|
BLAKE2b-256 | 9848aec893bb982dba78cf68331f423ce35d0e02f05e8c71120a402c5143f972 |