Skip to main content

Simple bencoding decode/encode library

Project description

Simple bencoding decode/encode library 🔖

Install

pip install bencodingpy

Usage

Decode

>>> from bencodingpy import decode

>>> decode(b'4:spam')
'spam'

>>> decode(b'i1234e')
1234

>>> decode(b'l4:spam4:eggse')
['spam', 'eggs']

>>> decode(b'd4:spaml1:a1:bee ')
{'spam': ['a', 'b']}

>>> with open('debian-12.5.0-amd64-netinst.iso.torrent', 'rb') as file:
...     decoded_torrent = decode(file)
...     print(decoded_torrent['announce'])
... 
http://bttracker.debian.org:6969/announce

Encode

>>> from bencodingpy import encode

>>> encode('spam')
b'4:spam'

>>> encode(1234)
b'i1234e'

>>> encode(['spam', 'eggs'])
b'l4:spam4:eggse'

>>> encode({'spam': ['a', 'b']})
b'd4:spaml1:a1:bee'

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

bencodingpy-1.0.2.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

bencodingpy-1.0.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file bencodingpy-1.0.2.tar.gz.

File metadata

  • Download URL: bencodingpy-1.0.2.tar.gz
  • Upload date:
  • Size: 69.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.7

File hashes

Hashes for bencodingpy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ac1b476b1f8ff2a9680f0402e5f8945e76d6e30bd09cd1b9da8ae171379029f6
MD5 92edb5902a85ceddf450ca461eb3f61c
BLAKE2b-256 f7701c948a405fe8536eb53f9c85f65c514c128e411468149f4d75df1798335c

See more details on using hashes here.

File details

Details for the file bencodingpy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: bencodingpy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.7

File hashes

Hashes for bencodingpy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc751078a3b97fa3e67039ccbe65c71c24982250164c60000f516bc4dde99ad8
MD5 df72d205921cca6ec4940e52018d13bf
BLAKE2b-256 0bf2580651fbde7748178334dc335f49266ce4909783b19bb483df27c634a1cc

See more details on using hashes here.

Supported by

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