Crystal library for the bencode data serialization format
Bencode is a simple data serialization format used by the popular BitTorrent P2P file sharing system.
It contains only four data types, namely:
- byte strings
- integers
- lists
- dictionaries
For more info see spec.
Add this to your application's shard.yml
:
dependencies:
bencoding.cr:
github: Hamdiakoguz/bencoding.cr
require "bencoding.cr"
# Decoding:
BEncoding.decode("d3:foo3:bar3:bazi42ee") # => {"foo" => "bar", "baz" => 42}
# Encoding:
BEncoding.encode("foo bar") # => "7:foo bar"
BEncoding.encode(42) # => "i42e"
BEncoding.encode([1, 2, 3]) # => "li1ei2ei3ee"
BEncoding.encode({"foo" => 1, "bar" => -10}) # => "d3:bari-10e3:fooi1ee"
- Fork it ( https://github.com/Hamdiakoguz/bencoding.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- Hamdiakoguz Hamdi Akoğuz - creator, maintainer