first commit
This commit is contained in:
41
pgserver/application/util/Aes.php
Normal file
41
pgserver/application/util/Aes.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user