$key = 'SK7381DNSU#&#@DS'; //key的长度保持16位 加粗 标识 $cipher = "AES-128-ECB"; $iv_len = openssl_cipher_iv_length($cipher); $iv = openssl_random_pseudo_bytes($iv_len); $encrypt_data = openssl_encrypt(json_encode($response), $cipher, $key, $options = 0, $iv, $tag); //加密后自带base64_encode 切勿重复encode