Skip to content

Instantly share code, notes, and snippets.

@alphaville
Created December 30, 2011 12:15
Show Gist options
  • Save alphaville/1539578 to your computer and use it in GitHub Desktop.
Save alphaville/1539578 to your computer and use it in GitHub Desktop.
Password Generator using linux RNG device
# Allow lowercase and uppercase digits and numbers and the underscore
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c5;
echo '';
# Allow more symbols:
< /dev/urandom tr -dc _A-Z-a-z-0-9#.*$%^* | head -c10;
echo '';
# And even more...
< /dev/urandom tr -dc _A-Z-a-z-0-9#.*$%^*,+=-?/ | head -c10;
echo '';
# Generate 5 random passwords of length 12
cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' |fold -w 12| head -n 5| grep -i '[!@#$%^&*()_+{}|:<>?=]'
# Using openssl:
openssl rand 9 -hex # Hexadecimal output
openssl rand 9 -base64 # Base64-encoded output
# Take the md5sum of the current timestamp
date | md5sum
# and then take the Base64 of the output if you like:
date | md5sum | base64
# Note: Replace /dev/urandom by /dev/random to generate an even "randomer" password
# however it performs rather bad and you'll have to wait a looooot! So if you
# want a faster but yet more random solution use:
dd if=/dev/random bs=1 count=20 | base64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment