Random Password Generator: Generate random password by a open source PHP class

Last weekend,  I passed very boring time in my home. Didn’t have that much work load. I am thinking to do something fun. And then I wrote a open source PHP class that generates Random password. Well, later on I used it in one of my clients’ project. Some of my friends also start using this class. So, I feel that I need to share with everyone. . 🙂

Source codes is available here:  http://github.com/eftakhairul/Random-Password-Generator

Let me show some examples:

$testPass =  new RandomPassword();
echo $testPass->useNumbers(3)->generatePassword(9);

Output:

QACror747

Again:

$testPass->useNumbers(2)->useSpecialChars(3);

echo $testPass->generatePassword(10);

Output:

OXAus#@^01

Leave a Reply to Doktor J Cancel reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Hmm class seems abit over the top, also listing all the chars is abit silly. i just wrote this, much easier

    [code]
    for ($i = 0; $i <= $length; ++$i) {
    $password .= chr(rand(47, 126));
    }
    [/code]

    • The problem with this is it does not guarantee any degree of complexity; it’s entirely possible for this snippet to still generate a password like “adahdaha” (only three unique characters, all lowercase) even though the valid character range includes uppercase, lowercase, numbers, and symbols.

  2. Pingback: PHP password generator | abidur rahman