How can a clear and unique salt be defined for the crypt function in PHP?

To define a clear and unique salt for the crypt function in PHP, you can generate a random string using a secure method like random_bytes() or openssl_random_pseudo_bytes(). This ensures that the salt is unpredictable and unique for each encryption.

// Generate a random salt using random_bytes()
$salt = base64_encode(random_bytes(16));

// Use the generated salt with the crypt function
$hashed_password = crypt($password, '$2y$10$' . $salt);