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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bencodingpy-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9e1fd4f0df3b9eabd3a9c508514a89731ef2a03da6d8d9b5d7cb07ea98f21a27
MD5 b27b2e2a7b649168ed716e28bb38b0e6
BLAKE2b-256 91deb02f7613b8bb469f1aa2861f2a88f60bc7fad736fb084040c0cbed3f79de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bencodingpy-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f17aad46454d5e2c7183793ac66104d928fc9b1ededd897dc9aadabf2dc6f126
MD5 c0e2127b6e91a144eee9e10b491806fd
BLAKE2b-256 19f9bbd55d4ceade03a0b27a525bd451f12b1b3231bec972deea59df5fb1a378

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