REncode -- Web safe object serialization
REncode was based on the BitTorrent BEncode module by Petru Paler, et al. Licensed by Bram Cohen, 2001-2002, modified by Connelly Barnes 2006-2007.
This module for Ruby was written by Mikael Wikman, 2014, and aims to be complient with the Connelly Barnes version 1.0.2
Usage
This implementation creates byte arrays, and expects byte arrays as argument. If you have a string, you could simply use str.bytes, or if you want to convert to string do arr.pack("C*")
require 'rencode'
REncode.dump({ 'awesome' => 'It works!' })
# => [CHR_DICT, '7'.ord, ':'.ord, 'awesome'.bytes, '9'.ord, ':'.ord, 'It works!'.bytes, CHR_TERM].flatten
REncode.parse([CHR_INT, '123'.bytes, CHR_TERM].flatten)
# => 123