Files
pgserver3.0/pgserver/application/util/Aes.php
annnj-company 130c1026c4 first commit
2026-04-17 18:29:53 +08:00

42 lines
597 B
PHP

<?php
namespace app\util;
class Aes {
public $key = '';
public $iv = '';
public $method = '';
/**
* 构造方法
*/
public function __construct($key, $iv = '', $method = 'AES-128-ECB')
{
$this->method = $method;
$this->key = $key;
$this->iv = $iv;
}
// 加密
public function aesEn($data){
return base64_encode(openssl_encrypt($data, $this->method,$this->key, OPENSSL_RAW_DATA , $this->iv));
}
//解密
public function aesDe($data){
return openssl_decrypt(base64_decode($data), $this->method, $this->key, OPENSSL_RAW_DATA, $this->iv);
}
}