OpenSSLの実装

// 暗号化
openssl_encrypt($data, $method, $key, $options, $iv);

// 復号
openssl_decrypt($data, $method, $key, $options, $iv);

暗号化時は bin2hex、復号時は hex2bin を用いる

$enc_string = bin2hex(openssl_encrypt($data, $method, $key, 0, $iv));
$dec_string = openssl_decrypt(hex2bin($data), $method, $key, 0, $iv);
$key = "passphrase";
$str = "abcdef";

$encrypt = openssl_encrypt($str, 'aes-256-ecb', $key);
echo $encrypt;

echo "\n";
$decrypt = openssl_decrypt($encrypt, 'aes-256-ecb', $key);
echo $decrypt;

$ php index.php
HR6LV+jGY5iU8Rycs+Jv8g==
abcde