复制代码 代码如下:
<?php
class AESMcrypt {
public $iv = null;
public $key = null;
public $bit = 128;
private $cipher;
public function __construct($bit, $key, $iv, $mode) {
if(empty($bit) || empty($key) || empty($iv) || empty($mode))
return NULL;
$this->bit = $bit;
$this->key = $key;
$this->iv = $iv;
$this->mode = $mode;
switch($this->bit) {
case 192:$this->cipher = MCRYPT_RIJNDAEL_192; break;
case 256:$this->cipher = MCRYPT_RIJNDAEL_256; break;
default: $this->cipher = MCRYPT_RIJNDAEL_128;
}
switch($this->mode) {
case 'ecb':$this->mode = MCRYPT_MODE_ECB; break;
case 'cfb':$this->mode = MCRYPT_MODE_CFB; break;
case 'ofb':$this->mode = MCRYPT_MODE_OFB; break;
case 'nofb':$this->mode = MCRYPT_MODE_NOFB; break;
default: $this->mode = MCRYPT_MODE_CBC;
}
}
public function encrypt($data) {
$data = base64_encode(mcrypt_encrypt( $this->cipher, $this->key, $data, $this->mode, $this->iv));
return $data;
}
public function decrypt($data) {
$data = mcrypt_decrypt( $this->cipher, $this->key, base64_decode($data), $this->mode, $this->iv);
$data = rtrim(rtrim($data), "\x00..\x1F");
return $data;
}
}
//使用方法
$aes = new AESMcrypt($bit = 128, $key = 'abcdef1234567890', $iv = '0987654321fedcba', $mode = 'cbc');
$c = $aes->encrypt('haowei.me');
var_dump($aes->decrypt($c));
aes加密
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 南合文斗.2007-陪君醉笑三千尘鸟人唱片】【FLAC+CUE】
- 群星《我们的歌第六季 第1期》[320K/MP3][90.72MB]
- 群星《我们的歌第六季 第1期》[FLAC/分轨][456.01MB]
- 李雨寰《Break Free》[320K/MP3][98.39MB]
- 草蜢.2001-《真经典》环球唱片[WAV+CUE]
- 群星.2009-第4届2008十大发烧唱片精选[FLAC+CUE]
- 丁红《女儿情》[DTS-WAV]
- 陈惠婷.2017-Voyager3【亚神音乐】【FLAC分轨】
- 群星.2001-华纳歌声魅影【华纳】【WAV+CUE】
- 张雨生.2016-雨后星空2CD【丰华】【WAV+CUE】
- 李雨寰《Break Free》[FLAC/分轨][533MB]
- 廖也欧《面朝大海》[320K/MP3][18.35MB]
- 廖也欧《面朝大海》[Hi-Res][24bit 48kHz][FLAC/分轨][170.14MB]
- s13T1夺冠五人名单都有谁 s13T1夺冠五人名单一览
- 英雄联盟T1战队队长都有谁 T1战队所有队长介绍