Return to Snippet

Revision: 8048
at August 30, 2008 02:52 by iTony


Initial Code
<?php
/**
* Random Password Generator
* @public
* @param int $length Length of password to generate
* @return string Returns randomised password
*/
function randomPword($length)
{
$seed = 'ABC123DEF456GHI789JKL0MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$seedLength = strlen($seed);
$random = '';
for ($i=1; $i <= $length; $i++)
{
$charPos = mt_rand(0, ($seedLength - 1));
$singleChar = substr($seed, $charPos, 1);
$random .= $singleChar;
}
return $random;
}
?>

Initial URL

                                

Initial Description

                                

Initial Title
Random password

Initial Tags
php, function

Initial Language
PHP