Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/ratopi/bencoding
- Owner: ratopi
- License: other
- Created: 2018-10-23T05:43:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-01T19:35:42.000Z (almost 5 years ago)
- Last Synced: 2024-09-30T03:42:11.433Z (about 2 months ago)
- Topics: bencode, bencoding, bittorrent, bittorrent-protocol, erlang
- Language: Erlang
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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