/bencodelix

simple bencode in elixir

Primary LanguageElixirMIT LicenseMIT

Bencodelix

** Bencode implementation as procotol **
stupid pure Elixir unfinished encoder decoder for Bencode decode String only

notes:

  • dict. value are converted in string or int while key decode as symbol
  • dict. keys order is not keep
  • when encoded line contain multiple concateted thing they are decode in a list in same order Bencode.decode("6:qwerty6:azerty") == ["qwerty","azerty"]

** Use Case **

  • see test for more exemples

Bencode.encode [123,"aze"] => "li123e3:azee"
Bencode.decode "li123e3:azee" => [123, "aze"]
dic = HashDict.new()
dic = Dict.put(dic, :hello, "world")
dic = Dict.put(dic, :number,42)
Bencode.decode(Bencode.encode dic) ==> dic