An implementation of Bencode encoding in Python 3
Usage
import bencode
bencode.encode(OrderedDict((1, 2), (b'eggs', b'spam')))
bencode.decode(b'i3e')
Type mapping for encoding:
Bencode type |
Python type |
|---|---|
Dictionary |
OrderedDict |
List |
list |
Byte string |
bytes |
Integer |
int |
Type mapping for decoding:
Python type |
Bencode type |
|---|---|
dict |
Dictionary |
list or tuple |
List |
bytes |
Byte string |
int |
Integer |
If OrderedDict is passed instead of plain dict, the order will be preserved.
Compact peer encoding
This package also includes functions for ‘compact’ peer encoding as per bep 0023. Though not part of bencode itself, compact peer encoding is often used with it. Mainline DHT and most trackers encode peer information in this format.
Usage:
from bencode.misc import pack_compact_peers_list, unpack_compact_peers_list
pack_compact_peers_list((('127.0.0.1', 8080), ('127.0.0.1', 9090)))
b'\x7f\x00\x00\x01\x1f\x90\x7f\x00\x00\x01#\x82'
unpack_compact_peers_list(b'\x7f\x00\x00\x01\x1f\x90\x7f\x00\x00\x01#\x82')
(('127.0.0.1', 8080), ('127.0.0.1', 9090))
Metadata
Release files for torrent-bencode 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 | Provenance | |
|---|---|---|---|---|
| torrent-bencode-0.2.tar.gz | 2.9 kB | Without provenance | Details |
Release files / torrent-bencode-0.2.tar.gz
| Download URL | torrent-bencode-0.2.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd04f8116776271ba007e151418276301226fb6978284bc0e20f4c55d784ca10
|
|
BLAKE2b-256 checksum How to use checksums |
dede9c6b868a63c0fca362bfa47a345c5161d2b6d2f3bf450d9862a66bd6885a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2
|
Security for torrent-bencode 0.2
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.