Skip to content

benwilber/bashids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Pure Bash implementation of the hashid algorithm from http://hashids.org/

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages