Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ratopi/bencoding

A fast encoder/decoder for the bittorrent data representation in pure Erlang
https://github.com/ratopi/bencoding

bencode bencoding bittorrent bittorrent-protocol erlang

Last synced: about 1 month ago
JSON representation

A fast encoder/decoder for the bittorrent data representation in pure Erlang

Awesome Lists containing this project

README

        

# bencoding

A simple encoder/decoder for decoding and encoding data in the bencoding style

## Mapping

* Bencode-integer will be converted to Erlang integers.
* Bencode-strings will be converted to Erlang binary strings.
* Bencode-list will be converted to Erlang lists.
* Bencode-dictionaries will be converted to Erlang maps. (#{})

## Use

Get it via hex.pm! Just add

{deps, [bencoding]}.

to your rebar.config.

See https://hex.pm/packages/bencoding for info about the hex package.

### Decoding

Use bencoding:decode/1 to decode any bencoded content.

Example: Reading a torrent file:

{ok, F} = file:read_file("test.torrent").
{ok, M, _} = bencoding:decode(F).
M.

M holds the result.

### Encoding

Use bencdoing:encode/1 to encode (with M from above):

{ok, B} = bencoding:encode(M).
B.

## Issues

If you miss any feature or found a bug, please let me know on github: https://github.com/ratopi/bencoding/issues