Skip to content

Instantly share code, notes, and snippets.

@denmojo
Created November 10, 2015 18:32
Show Gist options
  • Select an option

  • Save denmojo/086fbcb6a14db6cd1174 to your computer and use it in GitHub Desktop.

Select an option

Save denmojo/086fbcb6a14db6cd1174 to your computer and use it in GitHub Desktop.
#!/bin/bash
MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=~\`{[}]|\\:;\"\'<,>.?/"
# ==> Password will consist of alphanum and punct characters.
LENGTH="24"
while [ "${n:=1}" -le "$LENGTH" ]
# ==> So, if 'n' has not been initialized, set it to 1.
do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
# echo "$PASS"
let n+=1
done
echo "$PASS"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment