Pure Bash implementation of the hashid algorithm from http://hashids.org/
Switch branches/tags
Nothing to show
Clone or download
Latest commit 635304b May 27, 2017
Permalink
Failed to load latest commit information.
.travis.yml Uncompressed archive May 27, 2017
LICENSE Initial commit Nov 15, 2014
README.md rearrange badges May 27, 2017
bashids shellcheck pass May 27, 2017
tests.bats fix hashing zeros Oct 2, 2015

README.md

bashids

ghit.me Build Status

Pure Bash implementation of the hashid algorithm from Hashids.org

Usage

$ bashids -h
usage: bashids (-e|-d) [-s SALT -l MIN_LENGTH -a ALPHABET]  (hashid|ints)
    -e <encode>
    -d <decode>
    -s SALT (default: "")
    -l MIN_LENGTH (default: 0)
    -a ALPHABET (default: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890)
    -h <help>

Encoding

$ bashids -e -s MySalt 25 46 57
1liJyCK1

Decoding

$ bashids -d -s MySalt 1liJyCK1
25
46
57

Tests

bashids uses the bats BASH testing framework for tests.

Running tests

$ bats tests.bats 
 ✓ encode: empty
 ✓ encode: default salt
 ✓ encode: single number
 ✓ encode: zero hash
 ✓ encode: multiple numbers
 ✓ encode: salt
 ✓ encode: alphabet
 ✓ encode: minimum length
 ✓ encode: all parameters
 ✓ encode: alphabet without standard separators
 ✓ encode: alphabet with two standard separators
 ✓ encode: negative numbers
 ✓ encode: float numbers
 ✓ decode: empty
 ✓ decode: default salt
 ✓ decode: single number
 ✓ decode: multiple numbers
 ✓ decode: salt
 ✓ decode: alphabet
 ✓ decode: minimum length
 ✓ decode: all parameters
 ✓ decode: invalid hash
 ✓ decode: alphabet without standard separators
 ✓ decode: alphabet with two standard separators

24 tests, 0 failures