Created
July 1, 2011 13:43
-
-
Save Jach/1058565 to your computer and use it in GitHub Desktop.
Random password generator, remember a passphrase + unique key (such as sitename)
This file contains 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 | |
# Prints out (highly likely at least) 64 random characters, along with some truncations for common password length limits. | |
# Shows random characters in the printable set as well as just alpha-numeric. | |
# get rid of -s flag if you want to see what you type | |
# (possible enhancement for people who typo a lot: read into $p2 as well and only proceed if the entries are equal.) | |
read -s p | |
hash=`echo -n $p | sha256sum | sed -e 's/-//' | sed -e 's/ //'` | |
hash=`python -c "import random, sys, struct; random.seed(0x$hash); bits=[random.getrandbits(64) for i in range(200)]; sys.stdout.write(struct.pack('Q'*len(bits), *bits)); print"` | |
hash2=`echo $hash | tr -cd "[:graph:]" | head -c ${1:-64}` | |
hash=`echo $hash | tr -cd "[:alnum:]" | head -c ${1:-64}` | |
echo '64: '$hash | |
echo '50: '${hash:0:50} | |
echo '40: '${hash:0:40} | |
echo '20: '${hash:0:20} | |
echo '16: '${hash:0:16} | |
echo '12: '${hash:0:12} | |
echo '10: '${hash:0:10} | |
echo '08: '${hash:0:8} | |
echo '--' | |
echo '64: '$hash2 | |
echo '50: '${hash2:0:50} | |
echo '40: '${hash2:0:40} | |
echo '20: '${hash2:0:20} | |
echo '16: '${hash2:0:16} | |
echo '12: '${hash2:0:12} | |
echo '10: '${hash2:0:10} | |
echo '08: '${hash2:0:8} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment