Skip to main content

Fast, safe and non-recursive implementation of Bittorrent bencoding for Python 3

Project description

https://travis-ci.org/acatton/flatbencode.svg?branch=master

Fast, safe and thoroughly tested implementation of bencode in pure Python 3, without any C extension.

This is called flatbencode because the algorithm for decoding a bencode structure is non-recursive, thus preventing RuntimeException.

Usage

>>> from flatbencode import encode, decode
>>> encode({b'foo': [b'bar', 1]})
b'd3:fool3:bari1eee'
>>> decode(b'ldei0e0:e')
[OrderedDict(), 0, b'']

Run tests

$ pip install pytest hypothesis
$ py.test -v

Changelog

v0.2.1 (2016-10-22)

  • Do not accept strings as dictionary keys [Antoine Catton]

v0.2.0 (2016-10-22)

  • Raise an exception when there’s still data left. [Tim Ruffing, #2]

  • Use bytes as python dictionary keys (instead of strings) [Tim Ruffing, #2]

  • Sort dictionary keys when serializing (follows the BEP-0003) [Antoine Catton]

v0.1.0 (2016-06-12)

  • Initial release.

  • Can decode bencoding into a python datastructure.

  • Can encode a python datastructure into bencoding serialization format.

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

flatbencode-0.2.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file flatbencode-0.2.1.tar.gz.

File metadata

  • Download URL: flatbencode-0.2.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flatbencode-0.2.1.tar.gz
Algorithm Hash digest
SHA256 77397d5d0108835404f6f7cad640d403c7025a11812afc7e1df4b0f92589ba77
MD5 cd4bcc49a5ed496b1e371e73d67ce1e0
BLAKE2b-256 963ded36c2a94bef2ff1b7fc62ba932fa2eb4db3f7ea30c89da01b1c64ecbb8c

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