[PHP] Check Password Strength
Checks the strength of a password and return an integer value depening on it's strength
PHP Code:
function CheckPasswordStrength($password)
{
$strength = 0;
$patterns = array('#[a-z]#','#[A-Z]#','#[0-9]#','/[¬!"£$%^&*()`{}\[\]:@~;\'#<>?,.\/\\-=_+\|]/');
foreach($patterns as $pattern)
{
if(preg_match($pattern,$password,$matches))
{
$strength++;
}
}
return $strength;
// 1 - weak
// 2 - not weak
// 3 - acceptable
// 4 - strong
}
//usage
CheckPasswordStrength('password'); //1
CheckPasswordStrength('Password'); //2
CheckPasswordStrength('P4ssword'); //3
CheckPasswordStrength('P4ssw()rd'); //4
Re: [PHP] Check Password Strength
Nice, nice... might use a variation on this, thanks for the idea! :thumb:
Re: [PHP] Check Password Strength
Thanks for this! i am going to use this function in a Authentication class i am going to use.
Will give credit
:wave:
Re: [PHP] Check Password Strength
Thanks for sharing but I can't get this to work. Is there an update for the code?