const PASSWORD = 'abcdefghi1234567890';
const CIPHER_METHOD = 'AES-256-CBC';
function encrypt($str) {
$val = openssl_encrypt($str, CIPHER_METHOD, hash('sha256', PASSWORD, true));
return $val;
}
function decrypt($str) {
return openssl_decrypt($str, CIPHER_METHOD, hash('sha256', PASSWORD, true));
}
$plain_data = 'I am vijay';
$encrypted = encrypt($plain_data);
echo "Encrypted : ".$encrypted."
";
$decrypted = decrypt($encrypted);
echo "Decrypted : ".$decrypted."
";
?>
Output
Encrypted : zmuNrqZ+GwtQC5B0riJoMw==
Decrypted : I am vijay
No comments:
Post a Comment