 <p>According to php manual </p> <p><strong>random_bytes</strong> : Generates <strong>cryptographically secure</strong> pseudo-random bytes <strong>openssl_random_pseudo_bytes</strong> : Generate a pseudo-random string of bytes</p> <p>so main difference is the <strong>cryptographically secure</strong></p> <blockquote> <p>The openssl_random_pseudo_bytes() PHP function calls the RAND_psuedo_bytes() OpenSSL function, which the OpenSSL docs say should only be used for non-cryptographic purposes:</p> </blockquote> <p><a href="https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php" rel="nofollow">https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php</a></p>