https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_string_echo
把内容替换掉
<?php
$encrypt_algo = 'AES-256-CBC';
$encrypt_key = 'SEC_KEY_r65VPa61';
$encrypt_iv = 'SEC_IV_MSh65s6Ba';
// Datas :
$inputDatas = json_encode([
'codeClient' => '123456',
'codeSociete' => '01'
]);
echo ' JSON Datas input : ' . $inputDatas;
// ouput :
// JSON Datas input : {"codeClient":"123456","codeSociete":"01"}
// Coding datas
$encryptedDatas = openssl_encrypt($inputDatas, $encrypt_algo, $encrypt_key, 0, $encrypt_iv);
echo '<br>encrypted datas : ' . $encryptedDatas;
// output :
// encrypted datas : DD40QpQA7bvTILU2WHjnn81C1xXUX5h4tadZXrl6OoQsZdL0gY8fwjQTYD23/N2k
$encryptedUrlDatas = urlencode($encryptedDatas);
echo '<br>encrypted datas for URL : ' . $encryptedUrlDatas;
// output :
// encrypted datas for URL : DD40QpQA7bvTILU2WHjnn81C1xXUX5h4tadZXrl6OoQsZdL0gY8fwjQTYD23%2FN2k
// Company's action :
// Décodage des données
$decryptedDatas = openssl_decrypt(urldecode($encryptedUrlDatas), $encrypt_algo, $encrypt_key, 0, $encrypt_iv);
echo '<br>Decoded data : ' . $decryptedDatas;
// output :
// Decoded data : {"codeClient":"123456","codeSociete":"01"}
?>
打印出来的结果是
JSON Datas input : {"codeClient":"123456","codeSociete":"01"}
encrypted datas : DD40QpQA7bvTILU2WHjnn81C1xXUX5h4tadZXrl6OoQsZdL0gY8fwjQTYD23/N2k
encrypted datas for URL : DD40QpQA7bvTILU2WHjnn81C1xXUX5h4tadZXrl6OoQsZdL0gY8fwjQTYD23%2FN2k
Decoded data : {"codeClient":"123456","codeSociete":"01"}
标签:01,encrypt,encrypted,openssl,echo,123456,datas From: https://www.cnblogs.com/chucklu/p/16939535.html