shash: short hashes using php crc32 method
shash () {
if [ -z "$1" ]
then
echo "Usage: shash string"
else
php -r 'echo hash("crc32", "'$1'", FALSE)."\n";'
fi
}
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