kamper
Diamond Member
- Mar 18, 2003
- 5,513
- 0
- 0
Originally posted by: VirtualLarry
Actually, no. Link? The problem is not necessarily just generating a unique one, but a tamper-proof, provably unique one.Originally posted by: kamper
What's so hard about generating a unique id? Have you seen the uuid spec?
Here's some light reading for you
There're probably shorter documents around. Long story short, it's an algorithm specifically designed to produce numbers that are "guaranteed" to be unique.
I believe it takes into account your machine's MAC address, the date and time and, of course, a random component. If you generate a number correctly you are virtually assured that no one on earth will generate that same number, so long as they also follow the rules.
I don't know a whole lot about the algorithm but it actually concerns me that it's only 128 bits. Sure that's big, but IPv6 addresses are 128 bits too. Anyways, I suppose it would at least be reliable for the purposes you describe. Where I work, we use uuids as keys for our database. Instead of letting the database generate an autoincrement, we generate the key in the app and insert it, assuming that it will be unique (hasn't failed yet