I need to generate a unique identifier based on some information. There will be multiple clients and one server. Each client will call a web service at server for the first time registration. Each client will send system name (considered to be unique), logged in user name, date of registration, mac-address (probable) etc.
Based on this information, I want to generate a unique identifier for that particular user. My Server is written in PHP. I know some hash methods can generate some unique key, but what is the standard and what is being used generally?
Thanks for help.
An effective approach to this is to add a salt (a few characters known only to the server) to the concatenated details from the clients. Take a hash of that data. In the example below, the salt is mysalt
.
<?php
echo hash('ripemd160', 'mysalt' . clientHostname . clientUsername . clientRegistrationDate);
?>
This approach means that the hash can't easily be guessed/reverse-engineered by a third party.
One standard for unique identification is UUID. There are 5 versions to choose from depending on what data you can supply and how obfuscated it needs to be.
If you're able to install PECL extensions, there's a very good one: http://pecl.php.net/package/uuid. If not search for PHP UUID and you'll find some pure php implementations.