Created
September 19, 2019 16:14
-
-
Save zph/eea83e2623fc4f34efebe0187aa2c89a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Creates alnum passwords of roughly the length requested. | |
# Alt form xxd -g 2 -l 64 -p /dev/urandom | tr -d '\n' | |
# (But then has a smaller random space b/c it's [a-f0-9]. | |
# We ask openssl for COUNT * 4 to be overly safe that we'll have that amount | |
# available after stripping it down to only alphanumeric characters. | |
set -CEeuo pipefail | |
IFS=$'\n\t' | |
shopt -s extdebug | |
COUNT=${1:-25} | |
FULL_COUNT=$((COUNT * 4)) | |
openssl rand -base64 "$FULL_COUNT" | tr -cd "[:alnum:]" | head -c "$COUNT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment