Simple PHP Password Generator

This is a simple password generator written in PHP. Using MD5 random hexadecimals this is will produce strong password, and we also can define how length the password character.

// using md5 random
// $length = 8 can be change, its length of password character
function md5_pass($length = 8)
return substr(md5(rand().rand()), 0, $length);

<b>Your Random Password:</b><br />
    echo md5_pass();
<br />
<form method="post">
<input type="button" value="Generated"

Download Source
See in action:

Related posts:

  1. Twitter Cant Login Or Reset Password
  2. How To Insert HTML, Javascript, PHP Code Into Joomla 1.5 Administrator Page
  3. Hello world!

Share To Facebook | Tweet This

  • Forum Design

    Alternately, you can use the dechex function

    $random = ”; for ($i = 0, $i < $length; $i++) { $random .= dechex (mt_rand(0,15)); }
    return $random;

  • plate rack

    very cool code, i will try it on one of my web sites, thanks for share.

  • SERi

    as well helped to create the registration on its website, works great!

  • Edinburgh Driving School

    But this is only a pseudo-random generator.

  • Edinburgh Driving School

    But it is still very useful and not easy to crack a password like that.

  • hen dos

    Is PHP set up to send emails from your server? I use PHPMailer to send emails and it works fine.

  • hen dos

    i created a lil password generator to add to my site, to make it easy for lazy people like be quickly copy and paste a decent password, would it be a good idea to use such a feature on my site..

  • hen dos

    I need a strong password generator, do you have one? I have been all over the internet and all i find are weak, commonly repeated ones.