Here is a Simple Function to generate random unique string.
function
GenerateNumber($min, $max)
{
//
Create the meta-password
$sMetaPassword
= "";
global
$CONFIG;
$ahPasswordGenerator
= array(
"C"
=> array('characters' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'minimum' => $min, 'maximum' => $max),
//"S" =>
array('characters' => "!@()-_=+?*^&", 'minimum' => 2,
'maximum' => 2
"N" =>
array('characters' => '1234567890', 'minimum' => $min, 'maximum' =>
$max)
);
foreach
($ahPasswordGenerator as $cToken => $ahPasswordSeed)
$sMetaPassword .=
str_repeat($cToken, rand($ahPasswordSeed['minimum'],
$ahPasswordSeed['maximum']));
$sMetaPassword
= str_shuffle($sMetaPassword);
//
Create the real password
$arBuffer
= array();
for
($i = 0; $i < strlen($sMetaPassword); $i ++)
$arBuffer[] =
$ahPasswordGenerator[(string)$sMetaPassword[$i]]['characters'][rand(0,
strlen($ahPasswordGenerator[$sMetaPassword[$i]]['characters']) - 1)];
return
implode("", $arBuffer);
}
No comments:
Post a Comment