Project

z85rb

0.0
No commit activity in last 3 years
No release in over 3 years
Pure Ruby implementiation of Z85 encoding. A drop-in replace for Z85 C extension for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

z85rb - pure Ruby implementation of Z85 encoding

Installation

Add this line to your application's Gemfile:

gem 'z85rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install z85rb

Usage

require 'z85rb'
Z85rb.encode("\x86\x4f\xd2\x6f\xb5\x59\xf7\x5b") # => 'HelloWorld'
Z85rb.decode('nm=QNzY&b1A+]nf') # => 'Hello World!'

Encoding data not padded to a multiple of 4 will raise ArgumentError.

Difference to reference implementation in C:

When input binary form in encoding is not bounded to 4 bytes, or input string frame in decoding is not bounded to 5 bytes, the reference implementation returns NULL.

Instead of returning nil, we raise an ArgumentError.

Raising an exception conforms the specification. We guess that the reference implementation returns NULL is because C does not have native support for exceptions.

Difference to z85 C extension for ruby

This gem is a drop-in replace for z85 C extension. API is the same.

There is only one difference:

When input is invalid (not bounded to 4 or 5 bytes), this gem raises an ArgumentError while z85 C extension raises RuntimeError.

Contributing

  1. Fork it
  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 new Pull Request

References

License

0BSD