Skip to content

patrickgombert/Bencodex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bencodex

A encode/decode library for bencoding

Bencode supports four types of objects

  • string - Implemented as an ASCII encoded binary
  • integer - Encoded in base 10 ASCII
  • list - Ordered, heterogenious list
  • dictionary - 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"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages