$key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$data = 'Hello, World!';
$cipher = 'aes-256-cbc';
$key = 'your_secret_key';
$iv = 'your_iv';
$encrypted = openssl_encrypt($data, $cipher, $key, 0, $iv);
$decrypted = openssl_decrypt($encrypted, $cipher, $key, 0, $iv);
echo $encrypted . "\n";
echo $decrypted . "\n";
$data = 'Hello, World!';
$publicKey = file_get_contents('public.pem');
$privateKey = file_get_contents('private.pem');
openssl_public_encrypt($data, $encrypted, $publicKey);
openssl_private_decrypt($encrypted, $decrypted, $privateKey);
echo $encrypted . "\n";
echo $decrypted . "\n";
$data = 'Hello, World!';
$privateKey = file_get_contents('private.pem');
$publicKey = file_get_contents('public.pem');
openssl_sign($data, $signature, $privateKey, OPENSSL_ALGO_SHA256);
$verified = openssl_verify($data, $signature, $publicKey, OPENSSL_ALGO_SHA256);
echo $signature . "\n";
echo $verified . "\n";