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.tar.gz
(69.5 kB
view hashes)
Built Distribution
Close
Hashes for bencodingpy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745fba0740f4c05fe3eea996dd70c2f4d36639dadfb0563f39cc1cbba061bc23 |
|
MD5 | b823e9716e3259714ee489ee1e4a9345 |
|
BLAKE2b-256 | 5fe2deab14871ac0ed057086cd53dd9629429a725d21b20332c337a3a345eaf8 |