What are the potential pitfalls of using shell commands for encryption in PHP?

Using shell commands for encryption in PHP can introduce security vulnerabilities such as command injection attacks if user input is not properly sanitized. To mitigate this risk, it is recommended to use PHP's built-in encryption functions or libraries like OpenSSL for secure encryption operations.

// Using PHP's built-in encryption functions for secure encryption
$data = "Hello, world!";
$key = "secret_key";
$encrypted_data = openssl_encrypt($data, 'AES-256-CBC', $key, 0, '1234567890123456');
echo "Encrypted data: " . $encrypted_data;