سؤال

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???

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top