Skip to main content

Bencode

A module that mimics the json standard lib module interface for Bencode

Installation

Simply clone the repository and then run the following on the root dir of the repo.

python3 -m build && python3 -m pip install dist/bencode-0.0.1-py3-none-any.whl

Usage

Reading bencoded data

Both load and loads functions will decode bencoded data.

import bencode

decoded_dic = bencode.loads(encoded_data)

# deserializing bencoded data from a file
with open("bencoded_file.torrent", "rb") as fp:
    decoded_dic = bencode.load(fp)

Encoding data

Pragmatically, only dictionaries are encoded in real life applications of this encoding format, but any other supported types can be singularly encoded.

import bencode

peers_dic = {b'peers': [
                {b'127.0.0.1': b'29123'}, 
                {b'127.0.0.1': b'6432'}
            ]}

# b'd5:peersld9:127.0.0.15:29123ed9:127.0.0.14:6432eee'
bencoded_peers = bencode.dumps(peers_dic)

# serialize an object as a bencoded stream to a file:
with open("my_bencoded_file.torrent", "rb") as fp:
    bencode.dump(peers_dic, fp)

Metadata

Release files for bencode-vug 0.1.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 bencode-vug 0.1.0
File Size Uploaded Provenance Actions
bencode_vug-0.1.0.tar.gz 40.7 kB Without provenance Details for bencode_vug-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bencode-vug 0.1.0
File Interpreter ABI Platform Actions
bencode_vug-0.1.0-py3-none-any.whl Python 3 none any Details for bencode_vug-0.1.0-py3-none-any.whl

Total release size: 69.5 kB

Release files / bencode_vug-0.1.0.tar.gz

Download URL bencode_vug-0.1.0.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
87fac563b4638b5c0c47a0646ca0812cded030aa45fb51987147927576c2b779
BLAKE2b-256 checksum
How to use checksums
fb737db725069ff40a2f4822112cdff9d4b525117fdc619dc48928ebbd8f6fc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / bencode_vug-0.1.0-py3-none-any.whl

Download URL bencode_vug-0.1.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0426f71e7c8be30ae700a7e49985df0084816765d595c8c7de868c31c1848da
BLAKE2b-256 checksum
How to use checksums
aa5b6d006b84733f4f8760eb073923709fff67821e74fb467b7b1d827da987f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for bencode-vug 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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