bencoding
bencoding
Crystal library for the Bencoding data serialization format
What is bencoding?
Bencoding 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 the bencoding spec.
Installation
Add this to your application's shard.yml
:
dependencies:
bencoding:
github: t-richards/bencoding
Usage
require "bencoding"
# 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"
Contributing
- Fork it ( https://github.com/t-richards/bencoding/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
Contributors
- t-richards - Maintainer
- Hamdiakoguz Hamdi Akoğuz - creator
Repository
bencoding
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- almost 6 years ago
- February 16, 2018
License
MIT License
Links
Synced at
Fri, 22 Nov 2024 10:02:02 GMT
Languages