Jump to content

freak or unique


tinker

Recommended Posts

I'm after something truly unique about the system to help generate a unique id. I'm may going over the top with worst case scenario's but...

This is what ii've got so far:

srand( (double)microtime() * 1000);
print "\$id = ".md5(php_uname().uniqid(rand(), true))."<br>";

 

But

On Unix' date=' the output reverts to displaying the operating system information PHP was built on if it cannot determine the currently running OS.[/quote']

Which leads me to believe that this cannot be relied upon to be unique in all instances. Therefore what else can you suggest that will truly be unique to a particular system?

Link to comment
https://forums.phpfreaks.com/topic/86485-freak-or-unique/
Share on other sites

that's exactly why I wanted a prefix and thought of uname, but even that seem's to have a flaw. Two machine's setup identically, perfectly in sync, issuing an id simultaneously to the micro second (which is why I use microtime to seed srand, because that adds a second call to microtime (e.g. uniqid also uses)) and if uname fails then because of same installation it'll output same on both... what else is available?

Link to comment
https://forums.phpfreaks.com/topic/86485-freak-or-unique/#findComment-441916
Share on other sites

i've been asked to accommodate the possibility that at some point that a cms instance could be installed on numerous servers, all providing access to the same site, just from different routed access points to a network, or even from different networks (is it distributed servers).

 

It is possible that they could query a centralised id generation script, but that's extra overhead and depends upon a guaranteed route there, so i'm looking for something internal, i.e. can I access some internal system entropy, say from '/dev/urandom', i'm not guaranteed access to openssl (which has a good random number generator), and i've also been looking at PHP's 'mt_rand()'.

Link to comment
https://forums.phpfreaks.com/topic/86485-freak-or-unique/#findComment-441937
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.