Bash - Password

About

password in bash

Testing Complexity

Snippet to test the complexity of the password with:

MY_PASSWORD="myValue12" ; 

# Must have a digit, a lowercase letter, a uppercase letter
regex=$'.*[0-9]{1,}.*'; [[ ${MY_PASSWORD} =~ $regex ]] && \ 
regex=$'.*[a-z]{1,}.*'; [[ ${MY_PASSWORD} =~ $regex ]] && \
regex=$'.*[A-Z]{1,}.*'; [[ ${MY_PASSWORD} =~ $regex ]]

# If the exit status is 0, it's good otherwise, it's not
echo $?

Powered by ComboStrap