Question

am generating unique api keies using this function and storing into database.

strtoupper( md5( uniqid(rand(), TRUE ) ) );

is thr any possiblities of generating same hash key by above function???

Was it helpful?

Solution

Even though the unique value generated by uniqueid function is really pretty unique, there is considerable probability of collision when using MD5 hash algorithm (i.e. different values will result in the same hash value). In fact, MD5 is considered "cryptographically broken and unsuitable for further use" by US-CERT and if you're concerned about collisions, you should consider using SHA256/SHA512 algorithms instead.

OTHER TIPS

uniqid is based on the time in milliseconds, combine that with a random prefix and it is extremely unlikely.

See below for more info on uniqid: PHP: uniqid - Manual

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top