Created
August 18, 2016 07:50
-
-
Save darookee/c3b59e47fd62264112622b5a64d6e12b to your computer and use it in GitHub Desktop.
generate random password (hex or alphanumeric)
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/bash | |
| # generate a random password from /dev/urandom | |
| # usage: rpass <pwlength> <number_of_passwords> <h for hex> | |
| alnum="[:digit:][:alpha:]" | |
| hex="a-f[:digit:]" | |
| if [ "${3}" == "h" ]; then | |
| pwtype=$hex | |
| else | |
| pwtype=$alnum | |
| fi | |
| env LC_CTYPE=C tr -dc $pwtype < /dev/urandom | fold -w ${1:-32} | head -n ${2:-1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment