Mini Shell
<?php
define("encryption_method", "AES-128-CBC");
define("key", "key");
function encrypt($data) {
$key = key;
$plaintext = $data;
$ivlen = openssl_cipher_iv_length($cipher = encryption_method);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options = OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary = true);
$ciphertext = base64_encode($iv . $hmac . $ciphertext_raw);
return $ciphertext;
}
function decrypt($data) {
$key = key;
$c = base64_decode($data);
$ivlen = openssl_cipher_iv_length($cipher = encryption_method);
$iv = substr($c, 0, $ivlen);
$ciphertext_raw = substr($c, $ivlen + 32);
$original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $key, $options = OPENSSL_RAW_DATA, $iv);
return $original_plaintext;
}
$data = "Coucou Bonjour";
$crypt = "/iHVuMtREV8r43KZqq0gpFVleJJ0s86DWv2CmO5T9YOyJ6kQrciY7yl9dTTr+WNvNXiaKIgl6yATYIaVqSpXmQ==";
echo $crypt . "<br/>";
echo decrypt($crypt). "<br/>";
echo $GLOBALS["EncryptionKey"];
echo $CONSTANT;
?>