|
楼主 |
发表于 2017-8-24 16:54:12
|
显示全部楼层
江苏省南京市
- <?php
- if(isset($_POST['param']) and isset($_POST['key'])) {
- $aesUtil = new AESUtil();
- $body = $aesUtil->encode(trim($_POST['param']), ($_POST['key']));
- echo $body;exit;
- }
- class AESUtil {
- protected $mode = 'aes-128-ecb';
- public function encode($param, $skey) {
- $skey = strtolower($skey);
- $content = $param;
- $result = openssl_encrypt($content, $this->mode, hex2bin($skey), true);
- return strtoupper(bin2hex($result));
- }
- public function decode($param, $skey) {
- $skey = strtolower($skey);
- $content = hex2bin($param);
- $result = openssl_decrypt($content, $this->mode, hex2bin($skey), true);
- return $result;
- }
- }
复制代码 |
|