Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Serialization and deserealization of bencoded data used by bittorent protocol.
Haskell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bench
examples
res
src/Data
tests
.gitattributes
.gitignore
.mailmap
.travis.yml
ChangeLog
LICENSE
README.md
Setup.hs
TODO.org
bencoding.cabal

README.md

Synopsis

BEncode is JSON-like format used in bittorrent protocol but might be used anywhere else.

Description

This package implements fast seamless encoding/decoding to/from bencode format for many native datatypes. To achive more performance we use bytestring builders and hand optimized attoparsec parser so this library is considered as replacement for BEncode and AttoBencode packages.

Format

Bencode is pretty similar to JSON: it has dictionaries(JSON objects), lists(JSON arrays), strings and integers. However bencode has a few advantages:

  • Compactness: no spaces in between any values — nor lists nor dicts nor anywhere else.
  • Dictionaries always sorted lexicographically by the keys. This allow us to test data on equality without decoding from raw bytestring. Moreover this allow to hash encoded data (this property is heavily used by core bittorrent protocol).
  • All strings prefixed with its length. This simplifies and speed up string parsing.

Hovewer there are some disadvantages comparing with JSON:

  • Bencode is certainly less human readable.
  • Bencode is rarely used, except bittorrent protocol of course.

Documentation

For documentation see package hackage page.

Build Status

Build Status

Maintainer pxqr.sta@gmail.com

Feel free to report bugs and suggestions via issue tracker or the mail.

Something went wrong with that request. Please try again.