Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niamtokik/bencode
Bencode Erlang Implementation
https://github.com/niamtokik/bencode
bencode decode encode erlang torrent
Last synced: about 5 hours ago
JSON representation
Bencode Erlang Implementation
- Host: GitHub
- URL: https://github.com/niamtokik/bencode
- Owner: niamtokik
- License: bsd-4-clause
- Created: 2017-05-10T18:54:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T17:54:14.000Z (over 6 years ago)
- Last Synced: 2023-07-14T13:29:37.542Z (over 1 year ago)
- Topics: bencode, decode, encode, erlang, torrent
- Language: Erlang
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#bencode
Bencode Erlang Library Implementation
## Build
$ rebar3 compile
## Usage
You can encode Erlang terms to Bencoded string:
> {ok, E} = bencode:encode([1, 2, 3, mystring]).
{ok,<<"li1ei2ei3e8:mystringe">>}
> E.
<<"li1ei2ei3e8:mystringe">>You can also decode Bencoded string to Erlang terms:
> {ok, D} = bencode_decode(B).
{ok,[1,2,3,<<"mystring">>]}
> D.
[1,2,3,<<"mystring">>]If you want to parse torrent file:
> {ok, Torrent} = file:read_file("/path/to/my.torrent").
> {ok, Decoded} = bencode:decode(Torrent).
> Decoded.## Todo
- Decoding options
- Encoding options
- Benchmarking
- More documentation
- More Test Unit
- More Common Test
- Find better way to order keys in dictionary
## References- https://wiki.theory.org/BitTorrentSpecification#Bencoding
- http://fileformats.wikia.com/wiki/Torrent_file
- https://github.com/jlouis/benc
- https://en.wikipedia.org/wiki/Bencode