diff --git a/week 1/projects/Password Validator/passwordValidator.ps1 b/week 1/projects/Password Validator/passwordValidator.ps1 new file mode 100644 index 0000000..5a99d31 --- /dev/null +++ b/week 1/projects/Password Validator/passwordValidator.ps1 @@ -0,0 +1,19 @@ +# PowerShell Password Policy Checker + +$password = Read-Host "Enter a password" + +if ([string]::IsNullOrEmpty($password)) { + Write-Host "You must enter a password" + exit +} + +$hasLetter = $password -match "[a-zA-Z]" +$hasDigit = $password -match "[0-9]" +$hasSpecial = $password -match "[^a-zA-Z0-9]" +$longEnough = $password.Length -ge 12 + +if ($hasLetter -and $hasDigit -and $hasSpecial -and $longEnough) { + Write-Host "Password is strong" +} else { + Write-Host "Password is weak" +} diff --git a/week 1/projects/Password Validator/passwordValidator.sh b/week 1/projects/Password Validator/passwordValidator.sh new file mode 100755 index 0000000..b222db2 --- /dev/null +++ b/week 1/projects/Password Validator/passwordValidator.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +read -p "enter a password : " password + +if [[ -z $password ]] ; then + echo "you must enter a password" + exit; +fi + +if [[ ${#password} -ge 12 ]] && [[ $password =~ [a-zA-Z] ]] && [[ $password =~ [0-9] ]] && [[ $password =~ [^a-zA-Z0-9] ]]; then + echo "Strong!!" +else + echo "Weak" +fi