De forma bem simplificada eu apresento a voçês as funções para criptografia usando SSL:
Encriptando:
<?php
$string = 'texto-para-criptografar';
function encripta($string)
{
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '123';
$secret_iv = '312';
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
return $output;
}
echo encripta($string);
?>
Descriptando:
<?php
$string = 'VWthUTgxaStYcWZDQW10V29BOFlSV3dhaGxlL1AzOGlteHYvT2d3dVI2az0=';
function decripta($string)
{
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = '123';
$secret_iv = '312';
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
return $output;
}
echo 'texto descriptografado: '.decripta($string);
?>