bencoding

Version, currently master branch1 version
  • master branchlatestFeb 2, 2019

github.com/t-richards/bencoding

Crystal library for the Bencoding data serialization format

1 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  bencoding:
    github: t-richards/bencoding
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.26.1
License
MIT
Authors
Tom Richards, Hamdi Akoğuz

Dependencies

This version declares no dependencies.

README

bencoding

Build Status

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

  1. Fork it ( https://github.com/t-richards/bencoding/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors