Thursday 22 September 2011

How to generate a random password using php

Here there is a simple example for generate a random password using php, it is quite easy and simple to make.

$length =10; // the length of the required password length
$characters_to_use ="abcdef1234567890"; // characters are to be use in your password
for($i = 0; $i < $length; $i++)
{
$do = mt_rand(0,strlen($characters_to_use)-1);
$password = $password . $characters_to_use{$do};
}

echo $password; // here you can view the password 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...