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'
Metadata
Release files for bencodingpy 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bencodingpy-1.0.2.tar.gz | 69.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bencodingpy-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 87.2 kB
Release files / bencodingpy-1.0.2.tar.gz
| Download URL | bencodingpy-1.0.2.tar.gz |
|---|---|
| Size | 69.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac1b476b1f8ff2a9680f0402e5f8945e76d6e30bd09cd1b9da8ae171379029f6
|
|
BLAKE2b-256 checksum How to use checksums |
f7701c948a405fe8536eb53f9c85f65c514c128e411468149f4d75df1798335c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.7
|
Release files / bencodingpy-1.0.2-py3-none-any.whl
| Download URL | bencodingpy-1.0.2-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc751078a3b97fa3e67039ccbe65c71c24982250164c60000f516bc4dde99ad8
|
|
BLAKE2b-256 checksum How to use checksums |
0bf2580651fbde7748178334dc335f49266ce4909783b19bb483df27c634a1cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.7
|