|
@ -71,13 +71,13 @@ public class EncryptResponseBodyWrapper extends HttpServletResponseWrapper { |
|
|
public String getEncryptContent(HttpServletResponse servletResponse, String publicKey, String headerFlag) throws IOException { |
|
|
public String getEncryptContent(HttpServletResponse servletResponse, String publicKey, String headerFlag) throws IOException { |
|
|
// 生成秘钥
|
|
|
// 生成秘钥
|
|
|
// String aesPassword = RandomUtil.randomString(16);
|
|
|
// String aesPassword = RandomUtil.randomString(16);
|
|
|
String aesPassword = SM4Util.generateKey(); |
|
|
String aesPassword = RandomUtil.randomString(32); |
|
|
|
|
|
|
|
|
// 秘钥使用 Base64 编码
|
|
|
// 秘钥使用 Base64 编码
|
|
|
String encryptAes = EncryptUtils.encryptByBase64(aesPassword); |
|
|
String encryptAes = EncryptUtils.encryptByBase64(aesPassword); |
|
|
// Rsa 公钥加密 Base64 编码
|
|
|
// Rsa 公钥加密 Base64 编码
|
|
|
// String encryptPassword = EncryptUtils.encryptByRsa(encryptAes, publicKey);
|
|
|
// String encryptPassword = EncryptUtils.encryptByRsa(encryptAes, publicKey);
|
|
|
String encryptPassword = EncryptUtils.encryptBySm2Hex(encryptAes, publicKey); |
|
|
String encryptPassword = EncryptUtils.encryptByRsa(encryptAes, publicKey); |
|
|
|
|
|
|
|
|
// 设置响应头
|
|
|
// 设置响应头
|
|
|
servletResponse.addHeader("Access-Control-Expose-Headers", headerFlag); |
|
|
servletResponse.addHeader("Access-Control-Expose-Headers", headerFlag); |
|
@ -89,7 +89,7 @@ public class EncryptResponseBodyWrapper extends HttpServletResponseWrapper { |
|
|
// 获取原始内容
|
|
|
// 获取原始内容
|
|
|
String originalBody = this.getContent(); |
|
|
String originalBody = this.getContent(); |
|
|
// 对内容进行加密
|
|
|
// 对内容进行加密
|
|
|
return EncryptUtils.encryptBySm4(originalBody, aesPassword); |
|
|
return EncryptUtils.encryptByAes(originalBody, aesPassword); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|