The program generates a random 12 character password.
Code:
<?php
// creating a 12 character random password
/* rand function generates a random integer
The syntax is : rand ( [int $min, int $max] )
and it gives an integer output
you will get an integer between minimum and maximum numbers specified
(both inclusive) as output.
The minimum value for $min is zero (0). */
$r1 = rand(1,255);
$r2 = rand(1,255);
$r3 = rand(1,255);
/* Here the three random numbers are concatenated using the '.' operator
dechex function converts a dDecimal to hexadecimal
<?php echo dechex(10); will convert decimal 10 to hexadecimal number a. */
$number = dechex($r1) . dechex($r2) . dechex($r3);
$rand = rand(1,9999);
/*crc32 function calculates the crc32 polynomial of a string.
Syntax is : crc32 (string $str)
It generates checksum polynomial of 32-bit length and can be
negative integer too.
It is usually used to validate the integrity of data being transmitted.
To get an unsigned checksum use printf function : printf("%u\n", $checksum); */
$number=dechex(crc32($number)).$rand;
echo $number;
Bookmarks