Encrypt and Decrypt Secret Documents with PHP

$data_to_encrypt = ‘Secret Data Here!’;
$secret_key = ‘Secret_123’;
$encrypted = openssl_encrypt($data_to_encrypt, ‘aes256’, $secret_key, 0, ‘IV_16-bit_string’);echo $encrypted; // sh4XQQ1FWJiarQo4qp97OqOOF4sqA00VqBYjDWP+XbE=
$data_to_decrypt = ‘sh4XQQ1FWJiarQo4qp97OqOOF4sqA00VqBYjDWP+XbE=’;
$secret_key = ‘Secret_123’;
$decrypted = openssl_decrypt($data_to_decrypt, ‘aes256’, $secret_key, 0, ‘IV_16-bit_string’);echo $decrypted; // Secret Data Here!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store