Possible Duplicate:
Formulas to generate a unique id?
Basically I need to generate a unique number but I don’t want it to be too long, such as a UUID. Something half of that size (if not smaller).
Can anyone think of any ways to do this?
Basically I’m going to have an app which might be in use by multiple people and the app generates files and uploads them to the web server. Those names need to be unique.
I’m not looking to use a database table to keep track of this stuff, by the way.
Generate a UUID, and only take the first half the string.
If you’re concerned about generating duplicate IDs, your options are to make them non-random and auto-increment, or to check for the existence of newly generated IDs: