/**
* aes
*
*/
class aes{
private $key = "wt@36";
private $iv = "8401948501850295"; //只能是16字节
/**
*
* @param unknown_type $key
* @param string $iv 16 length
*/
function __construct($key,$iv=null){
$this->key = $key;
if (!empty($iv)){
$this->iv = $iv;
}
}
/**
* 加密
* @param string $value
* @return string
*/
function encrypt($value){
return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, $value, MCRYPT_MODE_CBC,$this->iv));
}
/*
* AES解密
*/
function decrypt($value){
return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, pack("H*",$value),MCRYPT_MODE_CBC, $this->iv);
}
}
分类
- .net (22)
- adf (11)
- android (3)
- article (180)
- astronomy (2)
- block chain (8)
- C# Code (9)
- c/c++ (2)
- cache (8)
- cloud (2)
- consensus (3)
- css (2)
- cve (1)
- db (55)
- digest (1)
- finance (2)
- go (3)
- gps (2)
- hardware (1)
- html (2)
- http (2)
- info (18)
- iot (1)
- it (3)
- java (32)
- javascript (7)
- jsp (2)
- linux (76)
- mail (14)
- math (1)
- message (8)
- mood (4)
- mq (2)
- network (22)
- php (9)
- protocol (4)
- push/pull (2)
- python (5)
- rpc (2)
- search (4)
- servlet (1)
- space (24)
- storage (15)
- technologys (103)
- templete (1)
- virtual machine (7)
- web server (25)
- windows (12)
-
近期文章
其他操作
链接