|
Generation of the casual password
This lesson will show you how to make generation of the casual password with help PHP. The following code includes also check on minimal and a maximum quantity of symbols. So …
<? php
$min=4; // a minimum quantity of symbols
$max=15; // a maximum quantity of symbols
$pwd = "";
for ($i=0; $i <rand ($min, $max); $i ++)
// Loading and check of symbols
{
$num=rand (48,122);
if (($num> 97 ** $num <122))
{
$pwd. = chr ($num);
}
else if (($num> 65 ** $num <90))
{
$pwd. = chr ($num);
}
else if (($num> 48 ** $num <57))
{
$pwd. = chr ($num);
}
else if ($num == 95)
{
$pwd. = chr ($num);
}
else
{
$i-;
}
}
echo $pwd; // a conclusion of the password
?>

|