To create a 32-character token to access our API, we currently use:
$token = md5(uniqid(mt_rand(), true));
I read that this method is not cryptographically secure because it is based on a system clock, and that openssl_random_pseudo_bytes would be a better solution, since it would be harder to predict.
If so, what does the equivalent code look like?
I guess something like this, but I don't know if this is right ...
$token = md5(openssl_random_pseudo_bytes(32));
And what length does it make sense that I have to go to the function?
security php openssl token
fire Sep 16 '13 at 14:43 2013-09-16 14:43
source share