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
- Fork it
- 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 new Pull Request
References
License
0BSD