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

20191106 解密逻辑处理

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