$password = "secret123"; $salt = "RandomString1324"; $hash = hash("sha256", $password . $salt); echo $hash; // Output: 7d4cd4c916d3a23f316442ff8e5dadf3839f7e0f147b45c7b84d5e5c7d48e5b5
$password = "secret123"; $salt = bin2hex(random_bytes(16)); $hash = hash("sha256", $password . $salt); echo $hash; // Output: 8fa10e0d17c1f71b44f0c8d58a9492a420a043d16f5efd9854525a1a2c525d28In this example, we generate a random string of 16 bytes before hashing the password with the SHA256 algorithm. This ensures that the salt is unpredictable and unique, and therefore adds extra security to the password. Package library: In this example, we use the PHP `random_bytes()` function to generate a random string. This function is included in PHP 7 and above, but for older versions of PHP, you would need to install the `random_compat` library to use this function. Overall, using hash salt is an important technique for improving password security. It is relatively easy to implement in PHP and can greatly increase the strength of hashed passwords.