-
-
Save mohssineAboutaj/00b2ed2c9d24424fbbf7a39144bfac60 to your computer and use it in GitHub Desktop.
Check for password strength, password should be at least n characters, contain at least one number, contain at least one lowercase letter, contain at least one uppercase letter, contain at least one special character.
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
<?php | |
$password_length = 8; | |
function password_strength($password) { | |
$returnVal = True; | |
if ( strlen($password) < $password_length ) { | |
$returnVal = False; | |
} | |
if ( !preg_match("#[0-9]+#", $password) ) { | |
$returnVal = False; | |
} | |
if ( !preg_match("#[a-z]+#", $password) ) { | |
$returnVal = False; | |
} | |
if ( !preg_match("#[A-Z]+#", $password) ) { | |
$returnVal = False; | |
} | |
if ( !preg_match("/[\'^£$%&*()}{@#~?><>,|=_+!-]/", $password) ) { | |
$returnVal = False; | |
} | |
return $returnVal; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment