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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.