/ Published in: PHP
Copied it for later use hehe
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * * @simple function to test password strength * * @param string $password * * @return int * */ function testPassword($password) { { return 1; } $strength = 0; /*** get the length of the password ***/ /*** check if password is not all lower case ***/ { $strength += 1; } /*** check if password is not all upper case ***/ { $strength += 1; } /*** check string length is 8 -15 chars ***/ if($length >= 8 && $length <= 15) { $strength += 1; } /*** check if lenth is 16 - 35 chars ***/ if($length >= 16 && $length <=35) { $strength += 2; } /*** check if length greater than 35 chars ***/ if($length > 35) { $strength += 3; } /*** get the numbers in the password ***/ /*** check for special chars ***/ /*** get the number of unique chars ***/ $strength += $num_unique_chars * 2; /*** strength is a number 1-10; ***/ $strength = $strength > 99 ? 99 : $strength; return $strength; } /*** example usage ***/ $password = 'php_tutorials_and_examples!123'; echo testPassword($password); ?>
URL: http://www.phpro.org/examples/Password-Strength-Tester.html