secret_key = isset($key) ? $key : 'yunxiekeji'; $this->method = $method; $this->iv = $iv; $this->options = $options; } /** * 加密方法,对数据进行加密,返回加密后的数据 * * @param string $data 要加密的数据 * * @return string * */ public function encrypt($data) { return base64_encode(openssl_encrypt($data, $this->method, $this->secret_key, $this->options, $this->iv)); } /** * 解密方法,对数据进行解密,返回解密后的数据 * * @param string $data 要解密的数据 * * @return string * */ public function decrypt($data) { return openssl_decrypt(base64_decode($data), $this->method, $this->secret_key, $this->options, $this->iv); } }