ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
实例代码 ```php <?php class Aes{ protected $key=''; protected $iv=''; /** * @param $key * @param $iv * @return $this * 配置 key iv */ public function instance($key,$iv){ $this->key=$key; $this->iv=$key; return $this; } /** * @param $input * @return string * 加密 */ public function encrypt($input) { $data = openssl_encrypt($input, 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA, $this->hexToStr($this->iv)); $data = base64_encode($data); return $data; } /** * @param $input * @return string * 解密 */ public function decrypt($input) { $decrypted = openssl_decrypt(base64_decode($input), 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA, $this->hexToStr($this->iv)); return $decrypted; } /** * @param $hex * @return string * hex转换 */ public function hexToStr($hex) { $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2) { $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } } ``` 可以直接复制使用,php的aes加密类库