A encode/decode library for bencoding
Bencode supports four types of objects
string
- Implemented as an ASCII encoded binaryinteger
- Encoded in base 10 ASCIIlist
- Ordered, heterogenious listdictionary
- String keys with heterogenious values in lexicographical order
Decode Bencode terms into Elixir terms
Bencodex.decode("i1e") # => 1
Bencodex.decode("3:foo") # => "foo"
Bencodex.decode("li1e3:fooe") # => [1, "foo"]
Bencodex.decode("d3:fooi1ee") # => %{"foo" => 1}
Encode Elixir terms into Bencode terms
The accepted types are integer, binary (string), list and map
Bencodex.encode(1) # => "i1e"
Bencodex.encode("foo") # => "3:foo"
Bencodex.encode([1, "foo"]) # => "li1e3:fooe"
Bencodex.encode(%{"foo" => 1}) # => "d3:fooi1ee"