Last active
September 28, 2021 00:53
-
-
Save fuzziebrain/5e731777811a38ced0d43b3714c6b890 to your computer and use it in GitHub Desktop.
Password generator with Bash
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
# SC => special characters allowed | |
SC="_" | |
while | |
_password=$(openssl rand -base64 $(($RANDOM % 6 + 15)) | tr '[:punct:]' $SC) | |
[[ | |
$(echo $_password | grep -o '['$SC']' | wc -l) -lt 2 | |
|| $(echo $_password | grep -o '[0-9]' | wc -l) -lt 2 | |
|| $(echo $_password | grep -o '[A-Z]' | wc -l) -lt 2 | |
|| $(echo $_password | grep -o '[a-z]' | wc -l) -lt 2 | |
]] | |
do true; done | |
echo $_password | |
# Example Use | |
# =========== | |
# RANDOM_SECRET=$(sh -c "$(curl -fsSL https://gist.githubusercontent.com/fuzziebrain/5e731777811a38ced0d43b3714c6b890/raw/e6b63c6386a59d8cb943094e43f81b6f58f662d0/generate_password.sh)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment