Created
August 14, 2020 13:37
-
-
Save rnkoaa/ce2d97c27398928de0116fad940a6ba7 to your computer and use it in GitHub Desktop.
generate random password on cli
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 | |
LENGTH=25 | |
if [ ! -z "$1" ] && [ $1 -gt 1 ]; then | |
LENGTH=$1 | |
fi | |
NUMBYTES=`echo $LENGTH | awk '{print int($1*1.16)+1}'` | |
openssl rand -base64 $NUMBYTES | tr -d "=+/" | cut -c1-$LENGTH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment