提交 b5250d34 编写于 作者: rushui.chen's avatar rushui.chen

20191106 解密逻辑处理

上级 c233c3d4
流水线 #16658 已失败 于阶段
in 0 second
...@@ -80,28 +80,16 @@ public class Test { ...@@ -80,28 +80,16 @@ public class Test {
// System.out.println(encryptEntity1Json); // System.out.println(encryptEntity1Json);
System.out.println("--------------------登录接口-------------"); System.out.println("--------------------登录接口-------------");
String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB";
BaseRequest login = new BaseRequest(); BaseRequest login = new BaseRequest();
login.setMobile("13024112588"); login.setMobile("13024112588");
login.setPassword("d0dcbf0d12a6b1e7fbfa2ce5848f3eff"); login.setPassword("d0dcbf0d12a6b1e7fbfa2ce5848f3eff"); //qq123456
String con = JSONObject.toJSONString(login); String con = JSONObject.toJSONString(login);
String contentResult = AESUtil.aesEncrypt(con, "YCPQPx4qpQjEjDea"); //十六位随机数
String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB";
String contentResult = AESUtil.aesEncrypt(con, "YCPQPx4qpQjEjDea");
String keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey); String keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest = new EncryptEntity(); EncryptEntity encryptTest = new EncryptEntity();
encryptTest.setContent(contentResult); encryptTest.setContent(contentResult);
encryptTest.setKey(keyResult); encryptTest.setKey(keyResult);
......
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.RSAUtil; import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -7,6 +8,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -7,6 +8,8 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
...@@ -27,4 +30,17 @@ public class CipherController { ...@@ -27,4 +30,17 @@ public class CipherController {
return PicaResponse.toResponse(rsaPublicKey); return PicaResponse.toResponse(rsaPublicKey);
} }
/**
* todo:上线前需要注释掉
* @param key
* @return
* @throws Exception
*/
@ApiOperation("解密操作")
@GetMapping(value = "/cipher/decrypt")
public PicaResponse<String> decryptPublicKey(@RequestParam String key) throws Exception {
return PicaResponse.toResponse(RSAUtil.decrypt(key, AESUtil.privateKey));
}
} }
...@@ -166,45 +166,27 @@ public class AESUtil { ...@@ -166,45 +166,27 @@ public class AESUtil {
* 测试 * 测试
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String KEY="zJJ$c5md3$yuuhWW"; // String KEY="zJJ$c5md3$yuuhWW";
System.out.println("-------------加密---------"); // System.out.println("-------------加密---------");
String content = "13024112666"; // String content = "13024112588";
System.out.println("加密前:" + content); // System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY); // System.out.println("加密密钥和解密密钥:" + KEY);
//
System.out.println("-------------解密---------"); // System.out.println(
String encrypt = aesEncrypt(content, KEY); // "-------------解密---------");
System.out.println("加密后:" + encrypt); // String encrypt = aesEncrypt(content, KEY);
String decrypt = aesDecrypt(encrypt, KEY); // System.out.println("加密后:" + encrypt);
System.out.println("解密后:" + decrypt); // String decrypt = aesDecrypt(encrypt, KEY);
// System.out.println("解密后:" + decrypt);
//请求参数解密处理 //请求参数解密处理
// String encrypt="DC7Sc7ydClKJztuIz/E/5fXuQ8hqdr4W8mxL/XACtqT2wzK3jBiRXnoPOvR9lANIinXInrdbY5rCIwTiI9DeWFiwPP7cSF0cjnQOY11oJLjVg9qV9VZQXbFyDYVhRv8bbto5hD4evryzbdPTq6A23fD5LmXFYnWKdbSzZfFUl/w="; String key="HW3jIbG2YmNLzciarYVrUPifLbKPnkxTItwXkFaYD+tUCS3i2GVHoPDKCgv6OTVvy84Ga36kD1Q/B57+/aHutGV8KL8NZp5LQC6qlXxC4c7oG1Inb8zYPPcHLqpChxAqxPEl1ivbepbQA5x6zJCNtXUCcVKmVhiqAqH68l3GoVQ=";
// String decrypt = RSAUtil.decrypt(encrypt,privateKey); String decrypt = RSAUtil.decrypt(key,privateKey);
// System.out.println(decrypt); System.out.println(decrypt);
// //System.out.println("YCPQPx4qpQjEjDea"); //System.out.println("YCPQPx4qpQjEjDea");
// String content="z9zZyUYwKkYy08l0s1qH9CSnoNnXZbbhHVbAUwGIsOXKPGeTkZFnbL1HYJQXBdKqGzKZt8E5lDzdTGUiUVkkK8GO27fsSrRMewY5T6ndSuo="; // String content="Rmlca6BiqwNi0NA+BWUsn6NU/0bCvXCMxNv166jvZDbjJxZyZVhOzGTsWsqYvqDbHDO/0lfihG1I5BXQbFyOEVvFl72tVVaxROolLtzYkO7pX1GgAYfqofEDmQuZmX18JdfOi1DWrWoO0+HQHD3lRw==";
// String result = AESUtil.aesDecrypt(content, decrypt); // String result = AESUtil.aesDecrypt(content, decrypt);
// System.out.println(result); // System.out.println(result);
} }
} }
spring.profiles.active=uat spring.profiles.active=dev
\ No newline at end of file \ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册