README.md

# erl_bencode

[![build](https://gitlab.com/erlang-dev/erl_bencode/badges/main/pipeline.svg)](https://gitlab.com/erlang-dev/erl_bencode/-/pipelines)
[![codecov](https://codecov.io/gl/erlang-dev/erl_bencode/graph/badge.svg?token=)](https://codecov.io/gl/erlang-dev/erl_bencode)
[![Release](https://gitlab.com/erlang-dev/erl_bencode/-/badges/release.svg)](https://gitlab.com/erlang-dev/erl_bencode/-/releases)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg?logo=apache&logoColor=red)](https://www.apache.org/licenses/LICENSE-2.0)
[![Documentation](https://img.shields.io/badge/Documentation-@hex.pm-purple)](https://hexdocs.pm/erl_bencode/index.html)


This is a library for encoding and decoding erlang terms to bencode text.
An easy way to uniformly send information and data structures accross platforms and language.

NOTE:
Encoding atoms and tuples are Erlang specific and is **not** intended to be used with other platforms or programing languages, doing so will result in unknown errors.

## Installation

### Rebar3

`erl_bencode` is built using **[rebar3](https://rebar3.org)**,
if this library is used with rebar3 simply put it in your rebar.config file:

```
{deps, [
    erl_bencode
    ]}.
```

### Other

If you don't use rebar3 it's possibly to get the latest version from **[gitlab](https://gitlab.com/erlang-dev/erl_bencode/-/releases)**.


## Build

    $ rebar3 compile


## Test

Simply run eunit with rebar3

    $ rebar3 eunit


## Usage

### Example

```
1> bencode:encode("Wardenclyffe").
{ok, "12:Wardenclyffe"}
2> bencode:decode("d6:wardeni23ee").
{ok, #{"warden" => 23}}
3> bencode:decode(valid_file_path).
{ok,#{"a" => "valid","file" => "path","this" => "is"}}
4> 
```