<?php
$data = [
'name' => 'Tom',
'age' => 20,
'sex' => 'm',
'contry' => '英国'
];
//php 7.1以下
require_once "Des.php";
$des = Des::share('key', 'asdfglkj'); //
$encrypt = $des->encrypt(json_encode($data));
echo 'DES加密后:'.$encrypt.'';
$decrypt = $des->decrypt($encrypt);
echo 'DES解密后:'.$decrypt.'';
//openssl 方式兼容上方
require_once "Des71.php";
$des = Des71::share('key', 'asdfglkj'); //asdfglkj
$encrypt = $des->encrypt(json_encode($data));
echo 'DES加密后:'.$encrypt.'';
$decrypt = $des->decrypt($encrypt);
echo 'DES解密后:'.$decrypt.'';
1