Unique ID generaion script
Moderator: General Moderators
Unique ID generaion script
script which will genrate 5-digit hexadecimal number?
Re: Unique ID generaion script
What about:
That could works.
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;
Re: Unique ID generaion script
Actually I forgot to mention that the number will be pseudo-random. If you want a real random number, you need somthing else then ordinary computer.
Read here: http://www.random.org/
Read here: http://www.random.org/
Re: Unique ID generaion script
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()); ...
We've discussed this recently - viewtopic.php?f=34&t=112311
There are 10 types of people in this world, those who understand binary and those who don't
Re: Unique ID generaion script
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?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.