[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
    Super Moberator dclamp's Avatar
    Join Date
    Aug 2006
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    3,083

    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

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (VBA, VB 6, VB.NET, C#)
    Senior Software Engineer MCP (VB 6 &amp; .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps &amp; Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007

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.