Last active
August 29, 2015 14:05
-
-
Save ashaindlin/06dfdc6afc9ce4b29bc5 to your computer and use it in GitHub Desktop.
Generate random passwords (r/dailyprogrammer Easy #4)
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 | |
# Generate random passwords. Usage: `./generate-password.sh [quantity [length]]` | |
case "$#" in | |
0) | |
QUANTITY=1 | |
LENGTH=32 | |
;; | |
1) | |
QUANTITY="$1" | |
LENGTH=32 | |
;; | |
2) | |
QUANTITY="$1" | |
LENGTH="$2" | |
;; | |
*) | |
echo "Usage: `basename $0` [quantity [length]]" | |
exit 1 | |
esac | |
cat /dev/urandom | tr -dc '[:print:]' | fold -w $LENGTH | head -n $QUANTITY |
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
$ ./generate-password.sh | |
~jV=1&t9_@4P%[tl9ZH=9V~/I1r20L!2 | |
$ ./generate-password.sh 5 | |
VI&d&a5{g9O6+Txt&*%wvm0CEn1<M5r+ | |
PCkguo.!_\:S\ JD;!G6i3 GcSLbVg7; | |
94aLKd}ELKM~c~{i'(ewY`$<_93%H7JO | |
G6GU.F1Pkl#,wpUUfO6"k'U;@1"}1P:[ | |
cv^by"Z%!wj$,K7C7U*_.'VGvik~/+Qc | |
$ ./generate-password.sh 3 16 | |
.f)u_EtZ \>|-E;a | |
d^K-EbAw&^\n2('* | |
\n28]\cjqQsrBVm! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment