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
 

Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.

 

7 thoughts on “Random Password Generator: Generate random password by a open source PHP class

  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]

    1. 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.

Leave a Reply

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

 

Read previous post:
Share your files in a network by SAMBA Server

SAMBA is very well known Opensource applications for file and printer sharing server in Unix and Linux. It supports the Server Message Block...

Close