Dead simple lightning fast base 62 (only) encoder based on the yab62 gem by Teng Siong Ong. Right now there are only few improvements over yab62:
- Index table modified to 0-9|A-Z|a-z instead of 0-9|a-z|A-Z
- Can encode integers bigger than 839299365868340352
- Slightly faster on some environments
Adds a to_b62 function to the Integer class that encodes any integer between 0 and 18446744073709551615 to base 62. The encode function is implemented as a C extension so it's much faster than a plain ruby implementation.
gem install b62
Or add it to your Gemfile as well:
gem 'b62', '~> 1.0'
## Use
82310.to_b62
B62.to_b62(2377965395771)