Created
September 5, 2012 17:01
-
-
Save rietta/3640002 to your computer and use it in GitHub Desktop.
Easy command line random hash generator for Mac OS X, Linux, and FreeBSD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
head -n 4096 /dev/urandom | openssl sha1 |
This is a really useful snippet. Thank you for sharing 👍
Even fancier:
% head -n 4096 /dev/urandom | openssl sha1 | awk '{print $2}' | cut -c1-6
a87a72
In your ~/.zshrc
:
alias rsha='head -n 4096 /dev/urandom | openssl sha1 | awk "{print \$2}" | cut -c1-6'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sha224 was invented for exactly this “shorter hash” purpose. This is a hash function with a 224-bit output, which NIST defined in order to “match” (administratively speaking) the proclaimed 112-bit security of 3DES. They defined SHA-224 by taking SHA-256, changing the conventional IV, and truncating the output. For the truncation, they took the first 224 bits. See also: https://csrc.nist.gov/publications/detail/fips/180/4/final
$ head -n 4096 /dev/urandom | openssl sha224
05cac32284221f1a2f9218d12c121f298dbc18f8e589da5023c69a43