Skip to main content

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 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": [
        ["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


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.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

bcoder-1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file bcoder-1.1.tar.gz.

File metadata

  • Download URL: bcoder-1.1.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

Hashes for bcoder-1.1.tar.gz
Algorithm Hash digest
SHA256 fd80dff3e0ef6033f36e7a785adcf597607abfe5935b2aa5a625c6e7713d4234
MD5 20bbe23452512cf2d08d18237d044b9d
BLAKE2b-256 8857f70cc3de6907a266d25a0e4318f61754550e802dc458cdbbc5d6bf3d3110

See more details on using hashes here.

File details

Details for the file bcoder-1.1-py3-none-any.whl.

File metadata

  • Download URL: bcoder-1.1-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

Hashes for bcoder-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3c947e8a4b91b45d5672daf716c9f1bf0e37e813640e781fdaf8393fa69717e
MD5 114d5ef6aba5f2f66c900a73f237c1f2
BLAKE2b-256 cb504488b433aa90fa7c12475ec574e2f534ec15edd7c2f29533855c2417da48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page