https://github.com/datacite/base32-url
https://github.com/datacite/base32-url
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/datacite/base32-url
- Owner: datacite
- License: mit
- Created: 2018-01-19T08:28:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T07:08:38.000Z (over 8 years ago)
- Last Synced: 2025-09-11T10:25:43.152Z (10 months ago)
- Language: Ruby
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://badge.fury.io/rb/base32-url)
[](https://travis-ci.org/datacite/base32-url)
An implementation of Douglas Crockfords Base32-Encoding in Ruby, with two modifications to make
the resulting strings more URL friendly:
* use lower case characters
* use two digits (mod 97-10, ISO 7064) for the checksum
see
## Installation
```
$ gem install base32-url
```
## Changes
```
0.5.0 - use mod 97-10 (ISO 7064) to calculate checksum
0.3.0 - encode into lower case characters, use * ~ _ ^ u for checksum
0.2.0 - added optional checksum
```
## Usage
```
#!/usr/bin/env ruby
require 'base32/url'
Base32::URL.encode(1234) # => "16j"
Base32::URL.encode(100**10, :split=>5, :length=>15) # => "02pqh-ty5nh-h0000"
Base32::URL.decode("2pqh-ty5nh-hoooo") # => 10**100
Base32::URL.encode(1234, checksum: true) # => "16j82"
Base32::URL.decode("16j82", checksum: true) # => 1234
```
## Development
We use test-unit for unit testing:
```
bundle exec rake
```
Follow along via [Github Issues](https://github.com/datacite/base32-url/issues).
### Note on Patches/Pull Requests
* Fork the project
* Write tests for your new feature or a test that reproduces a bug
* Implement your feature or make a bug fix
* Do not mess with Rakefile, version or history
* Commit, push and make a pull request. Bonus points for topical branches.
## License
**base32-url** is released under the [MIT License](https://github.com/datacite/base32-url/blob/master/LICENSE.md).