i am developing an iphone app , i need to assign every user with a 5 characters unique key ( consisting of integers and alphabets ) like whoisHere and pmesssenger applications .
the problem is that the key should be universally unique , every two user shall never have the same key.
the information i collected up now is that :
1- i can use the iphone uid or CFUUID Class to generate key locally , but i'm not quit understand how to converted successfully to 5 characters unique key .
2- i can make the generation of the key global , for example , the app shall connect to a server to get unique key .
in the other hand , i want the user to keep the Uid even he/she changes the device , for example according to pmessenger application website , the user can keep the uid.
" you can keep your PMiD if you change phones... In order to do that, you only have to restore your new phone from a backup of your old phone... The PMiD will be transfered to the new phone, and don't forget to uninstall pMessenger from the old phone, if you sell your old phone, and the new user download pMessenger he will get a completely different PMiD "
so , how can i possibly do that ? thanks in advance .
Is there a specific reason why the unique key has to be 5 characters? Like Marc B said, it would be easy to predict if you assigned them consecutively...
I would suggest generating the key locally. Here's my suggestion: convert the UID locally, and store it in a cloud server (like a MySQL database, for example), in the same row as the device's UID. Then, when the app starts, it can check in the database whether or not the device's UID is being used, if so, it uses the associated unique character code.
In other words, it's difficult for the app to make a unique ID if it's not aware of the ones that have already been created. An online database could solve that problem.