Skip to main content

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 types
  • BEncoder - handle encoding of common Python types to bytes 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": [
        [b"udp:..."],
        [b"udp:..."],
    ],
    b"info": {
        b"piece": b"xfsasf",
        b"piece length": 123,
    },
}

encoded = encoder.encode(data)

NOTE: BEncoder is spec-strict (BEP 3). Only bytes, int, list, and dict with bytes keys are accepted. Pass str through .encode("utf-8") yourself if you need to encode text.

Release files for bcoder 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bcoder 2.0
File Size Uploaded
bcoder-2.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bcoder 2.0
File Interpreter ABI Platform
bcoder-2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / bcoder-2.0.tar.gz

Download URL bcoder-2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d1fe8b934a5b483cd991da624202b1825d69b009f4816c01a2e750f81dabc287
BLAKE2b-256 checksum
How to use checksums
3049589554069b6db78f6ac63b72f71701a4b9a3fc2afd7e885ed4856446e964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / bcoder-2.0-py3-none-any.whl

Download URL bcoder-2.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8da611e2b6bdd392805b752402d24238090180cea2e4a66b67f28c8c58e4a22b
BLAKE2b-256 checksum
How to use checksums
17a64c616cfe03647212013ef2124e01700a1958b0fbffd5597570415b97c6d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

2.0 This release

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page