Letter/cijfer generator
Werkt precies hetzelfde.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?
//** random letter/num generator **//
function NumcharGen($length, $caps)
{
if ($caps == 1)
$letters = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890";
else
$letters = "abcdefghijklmnopqrstuvwxyz1234567890";
for ($i = 1; $i <= $length; $i++)
{
$randnum = rand(0, strlen($letters));
if ($i == 1)
$randchar = substr($letters, $randnum, 1);
else
$randchar .= substr($letters, $randnum, 1);
}
return $randchar;
}
$password = NumcharGen(10,1);
echo $password;
?>
//** random letter/num generator **//
function NumcharGen($length, $caps)
{
if ($caps == 1)
$letters = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890";
else
$letters = "abcdefghijklmnopqrstuvwxyz1234567890";
for ($i = 1; $i <= $length; $i++)
{
$randnum = rand(0, strlen($letters));
if ($i == 1)
$randchar = substr($letters, $randnum, 1);
else
$randchar .= substr($letters, $randnum, 1);
}
return $randchar;
}
$password = NumcharGen(10,1);
echo $password;
?>
Werkt precies hetzelfde als de vorige. Maak van de NumcharGen(10, 1): NumcharGen(10, 0) en hij laat geen caps meer zien in de gegenereerde code.