Unique ID generaion script
Posted: Fri Feb 05, 2010 12:49 am
script which will genrate 5-digit hexadecimal number?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
srand(time());
$x = dechex(rand(1,16^5)-1);
$zero = "";
if(strlen($x) < 5)
for($i = strlen($x); $i<=5;$i++)
$zero .= "0";
$result = $zero.$x;
It's vulnerable to bruteforce seed attack, which allows the attacker to predict the generated "random" strings.dejvos wrote:What about:Code: Select all
srand(time()); ...
Yes, they exist. Did you have any particular problem you needed help with? That's what we tend to do here - "help" rather than "do your work for you"shreehart wrote:script which will genrate 5-digit hexadecimal number?