In plain English: Functions such as rand(), mt_rand(), and uniqid()
are predictable. They are fine for games and samples, but not for tokens,
passwords, salts, nonces, or other secrets.
Why it matters: If an attacker can predict a token, they may be able to guess password-reset links, CSRF tokens, session identifiers, or API keys.
$token = uniqid();
$password = password_hash(mt_rand(), PASSWORD_DEFAULT);
$nonce = (string) rand();
$token = bin2hex(random_bytes(32));
$code = random_int(100000, 999999);
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
random_bytes() is for tokens and salts. random_int() is for numeric codes.
password_hash() handles password salts for you.
rand(), mt_rand(), uniqid(), lcg_value(),
str_shuffle(), and array_rand()token, secret, password, nonce, salt, csrf, or api_keypassword_hash(), hash_hmac(), hash(),
openssl_encrypt(), openssl_sign(), cookie functions, or session ID
functionsrandom_bytes() or random_int().hash() or hash_hmac() uses a non-cryptographic checksum such as
xxh128, crc32, fnv1a64, or murmur3.random_bytes() for tokens, salts, and nonces.random_int() for numeric verification codes.password_hash() for passwords.uniqid() for anything security-sensitive.E0056 has no configuration options and is enabled by default.