I've been using
$string = bin2hex(openssl_random_pseudo_bytes(16)) . uniqid();
Because I need some string that is both crytopgrahically secure and unique. Question is: is this a naive approach? By using the result of uniqid() tacked onto the end of the string,am I giving away any information that might compromise the security of the string? I ask this because uniqid() is based on system time, and my concern is whether that could give any information away that allows an attacker to guess future outputs?
Thanks
You should use one from the following to generate crytopgrahically secure unique string/number,
bin2hex(openssl_random_pseudo_bytes(16, TRUE)); // Refer manual - (PHP 5 >= 5.3.0, PHP 7)bin2hex(random_bytes(16)); // Refer manual - (PHP 7)random_int(100, 999) // Refer manual - (PHP 7)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With