Tool to decode and encode .torrent files
Project description
bcoder
About
A Python package to handle bencoded values, a serialization format commonly used in .torrent
files within
the BitTorrent protocol.
Usage
There are 2 types of classes:
BDecoder
- handle decoding of bencoded data to common Python typesBEncoder
- handle encoding of common Python types tobytes
type
Example of BDecoder
usage:
from bcoder import BDecoder
decoder = BDecoder()
with open("file.torrent", "rb") as file:
data = file.read()
decoded = decoder.decode(data)
Example of BEncoder
usage:
from bcoder import BEncoder
encoder = BEncoder()
data = {
b"announce-list": [
["udp:..."],
["udp:..."],
],
"info": {
"piece": b"xfsasf",
"piece length": 123,
},
}
encoded = encoder.encode(data)
NOTE: BEncoder
can handle mixed types of Python strings - bytes
and str
.
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
bcoder-1.0.tar.gz
(3.7 kB
view details)
Built Distribution
bcoder-1.0-py3-none-any.whl
(5.0 kB
view details)
File details
Details for the file bcoder-1.0.tar.gz
.
File metadata
- Download URL: bcoder-1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
acbec5bc5d1eaea8fd20fce005c04198aa69057afe61f60888d829e2bd0b4011
|
|
MD5 |
2c2a8a1f61d3608436648b2da5b0a251
|
|
BLAKE2b-256 |
ac41fdab45df69b575b7adb3d7d545ac705861cd56f0e2f27efa2fe591ee7811
|
File details
Details for the file bcoder-1.0-py3-none-any.whl
.
File metadata
- Download URL: bcoder-1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
016345ad7e633051d840f6368d0a4d9977439f796f840a13b3b58d03d9917f95
|
|
MD5 |
0deb93aa70abf9d1a6edfad92cf25c48
|
|
BLAKE2b-256 |
a75fb67b8d4c9af4d6d9fe4122adfc200a910886c2b046865f8e822976c06a31
|