Password complexity calculator
Results 1 to 9 of 9

Thread: Password complexity calculator

  1. #1
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,735

    Password complexity calculator

    Something I was playing around with for a tool to roughly calculate the difficulty of guessing a password, just based on types of characters uses and the length of the password. (I.e., it does not try to consider things like dictionary words versus random strings, most commonly used characters, etc.)
    PHP Code:
    /**
     * Calculate the complexity of a password as the possible permutations
     * for the types of characters used and the password length. Does not
     * consider things like dictionary words, common patterns, et cetera
     * 
     * @param string $password
     * @return string (Numeric string from BCMath calculation)
     */
    function PasswordComplexity($password)
    {
        if(
    strlen($password) < 1
        {
            return 
    '0';
        }
        
    $charsets = array(
            
    '/[a-z]/' => 26,
            
    '/[A-Z]/' => 26,
            
    '/\d/' => 10,
            
    '/[^a-zA-Z0-9]/' => 10// kludge for any other characters!
        
    );
        
    $chars 0;
        foreach (
    $charsets as $regex => $num)
        {
            
    $chars += preg_match($regex$password) ? $num 0;
        }
        return 
    bcpow($charsstrlen($password));

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  2. #2
    Junior Member im_dalecosp's Avatar
    Join Date
    Aug 2016
    Posts
    6
    Proving XKCD right, I see!

  3. #3
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,735
    Quote Originally Posted by im_dalecosp View Post
    Proving XKCD right, I see!
    Yep.
    Code:
    'Tr0ub4dor&3':
      269561249468963094528
    'correcthorsebatterystaple':
      236773830007967588876795164938469376


    Sometimes size does matter.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  4. #4
    Junior Member im_dalecosp's Avatar
    Join Date
    Aug 2016
    Posts
    6
    Hey, if you're a mod can you approve my post in Feedback? (Maybe you're not ...)

  5. #5
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,735
    Quote Originally Posted by im_dalecosp View Post
    Hey, if you're a mod can you approve my post in Feedback? (Maybe you're not ...)
    I'll copy/paste it into the private team forum here, just to keep that stuff out of the public eye.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  6. #6
    Junior Member im_dalecosp's Avatar
    Join Date
    Aug 2016
    Posts
    6
    Heheh, thanks. Perhaps I should remove my avatar ...

  7. #7
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,735
    I posted in the team forum and moved your Feedback thread to our ultra-secret, if-I-told-you-I'd-have-to-shoot-you forum. Hopefully an admin will fix things or be in contact with you soon.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  8. #8
    Junior Member im_dalecosp's Avatar
    Join Date
    Aug 2016
    Posts
    6
    Hey, he did! It took some back-and-forth, but I got my account back. Special thanks to Brad Jones at Quinstreet ...

    I just thought I'd post here and tell you that, Nog! ~~im_dalecosp~~

  9. #9
    Junior Member im_dalecosp's Avatar
    Join Date
    Aug 2016
    Posts
    6
    And since the thread was moved, I can't click "Resolved", but please do know Brad Jones that your hard work is appreciated!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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