Quick Password Policy Function in PHP
PHP, Security December 17th, 2008Just a quick password policy function in php. Didn’t want to have to dig around to figure out how to do it again, so I’m just posting it here
/* * * * * * * * * * * * * * * * * * * * * * * * *
Password Policy requires
– at least 8 characters
– at least 1 lower case
– at least 1 upper case
– at least 1 digit
* * * * * * * * * * * * * * * * * * * * * * * * * /
function pwdPolicy($pwd){
$policy = “/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/”;
if(preg_match($policy, $pwd, $matches)){
return true;
} else return false;
}




March 16th, 2010 at 8:13 am
Good snippet. Would be a bit more useful with variables instead of static values.
Also your double quotes are copying as italic double quotes and your comment closing tag has an extra space which is breaking it