shash: short hashes using php crc32 method

2018-12-02 16:00
shash () {
  if [ -z "$1" ]
    echo "Usage: shash string"
    php -r 'echo hash("crc32", "'$1'", FALSE)."\n";'

I add this function to my .bash_profile so I can create short hashes from the command line. Not for anything serious, mainly when I want to generate a random username or something. There are of course many ways (likely better) to create short hashes, but I use the crc32 approach w/in my php code often, so I like the consistency. Use it like so:

$ shash hello

outputs: 3d653119