I have a database of users that are identified by their device udid (which got deprecated in iOS 5). I need a new way to identify devices that will not generate strings that already exist in my database.
The udid used to be SHA1(SerialNumber + IMEI + WiFiAddress + BluetoothAddress).
Is it safe to use the output of something like MD5(MACAddress) as my new way to identify devices? From what I’ve read it seems like MD5 and SHA-1 output different lengths of strings (respectively 128 and 160 bits), but I’m just making sure I’m not missing anything here. I really don’t want to end up with duplicate identifiers…
Just use
SHA1(MAC | 0001)instead of the previous one. The chance of creating a SHA1 that already exists is unlikely to the extreme, as it would indicate a real problem in the SHA1 algorithm (a collision). Note: I presume that + means concatenation, I’ve used | as concatenation.You can increase the counter (in characters or something else, try for 4 bytes) at the end if you need another unique identifier.
Although MD5 is probably safe enough for this purpose, I would still try and avoid the use of this broken hash – just keep with SHA1 (or move to SHA-256).