[PHP] Check Password Strength-VBForums
Results 1 to 3 of 3

Thread: [PHP] Check Password Strength

Hybrid View

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    [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 

  2. #2
    Moderator
    Join Date
    Jan 2005
    Location
    Sydney
    Posts
    13,621

    Re: [PHP] Check Password Strength

    Nice, nice... might use a variation on this, thanks for the idea!

  3. #3
    Terrible Member dclamp's Avatar
    Join Date
    Aug 2006
    Location
    United States
    Posts
    3,082

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.