Skip to content

Instantly share code, notes, and snippets.

@rietta
Created September 5, 2012 17:01
Show Gist options
  • Save rietta/3640002 to your computer and use it in GitHub Desktop.
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.
#!/bin/sh
head -n 4096 /dev/urandom | openssl sha1
@crmpicco
Copy link

This is a really useful snippet. Thank you for sharing 👍

@soniah
Copy link

soniah commented Nov 16, 2023

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