Giter Site home page Giter Site logo

hyperimpose / bencode Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

An erlang implementation of Bittorrent’s bencode format. See: http://bittorrent.org/beps/bep_0003.html

License: Other

Erlang 100.00%
bencode bencode-decoder bencode-encoder bencode-parser erlang erlang-libraries erlang-library erlang-otp

bencode's Introduction

bencode

An erlang implementation of Bittorrent’s bencode format. See: http://bittorrent.org/beps/bep_0003.html

Notes and Warnings

  • There is no depth limit.
  • No error handing. Invalid input will cause a crash.

Build

This library can be built with rebar3: $ rebar3 compile

or you can include it in your projects as a dependency in rebar.config:

{deps, [%% ... Other dependencies
       {bencode, {git, "https://github.com/hyperimpose/bencode.git", {branch, "master"}}}]}.

API Usage

There are two functions exported by bencode: decode/1 and encode/1.

%% Encode an erlang term:
%%
%% This function will return the following bencoded binary:
%% <<"d4:testi123ee">>
bencode:encode(#{<<"test" => 123>>}).

%% Decode an erlang term:
%%
%% This function will return an erlang dictionary:
%% #{<<"test" => 123>>}
bencode:decode(<<"d4:testi123ee">>).

%% See the next section for the supported terms and their equivalents.

Term Mapping

The bencoded values map to Erlang terms as follows:

BencodeErlang
dictionariesmap() #{} (If there are duplicate keys the last one is kept)
listslist() [] (Including strings/iolists etc.)
integersinteger()
stringsbinary()

Atoms or other terms are not supported.

License

This implementation of bencode is licensed under the BSD 3-Clause “New” or “Revised” License. A copy of this license is included in the file COPYING.

bencode's People

Contributors

hyperimpose avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.