Answers
class AES_128_CW {
private $_iv = '';
private $_secret = '';
public function __construct($iv,$secret){
$this->_iv = substr($iv.'0000000000000000', 0,16);//可以忽略这一步,只要你保证iv长度是16
$this->_secret = hash('md5',$secret,true);
}
public function decode($secretData){
return openssl_decrypt(urldecode($secretData),'aes-128-cbc',$this->_secret,false,$this->_iv);
}
public function encode($data){
return urlencode(openssl_encrypt($data,'aes-128-cbc',$this->_secret,false,$this->_iv));
}
}
miemie
answered 10 years, 1 month ago