What are the differences between encryption and hashing in the context of PHP programming, and why is it important to distinguish between the two?

Encryption is a reversible process that converts data into a format that can be decrypted back to its original form. Hashing, on the other hand, is a one-way process that converts data into a fixed-length string of characters that cannot be reversed. It is important to distinguish between the two because encryption is used to protect sensitive data while hashing is used for verifying data integrity or storing passwords securely.

// Example of using encryption in PHP
$plaintext = "Hello World";
$key = "secret_key";
$encrypted = openssl_encrypt($plaintext, 'AES-256-CBC', $key, 0, '1234567890123456');
echo "Encrypted: $encrypted";

// Example of using hashing in PHP
$password = "password123";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
echo "Hashed Password: $hashed_password";