Bash - Password

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

Table of Contents

1 - About

password in bash

2 - 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 $?
Advertising