mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
支付宝登录
This commit is contained in:
@@ -263,38 +263,12 @@ public class SpringBootTestController {
|
||||
private NotificationService notificationService;
|
||||
|
||||
@Test
|
||||
public void decryptPhoneNum(){
|
||||
// 前端接口返回的加密信息
|
||||
String response ="CunEGSbDxsQaKllc35Q+4lJdLiprZhrHFt9er/ZriETVHv2IrtZsmC8cA6DE5l8GgzvgHCPdGp1iUJQhNyKog==";
|
||||
//1. 获取解密所需要的参数
|
||||
Map<String, String> openapiResult = com.alibaba.fastjson.JSON.parseObject(response, new TypeReference<Map<String, String>>() {}, Feature.OrderedField);
|
||||
String charset = "UTF-8";
|
||||
String encryptType = "AES";
|
||||
String content = "CunEGSbDxsQaKllc35Q+4lJdLiprZhrHFt9er/ZriETVHv2IrtZsmC8cA6DE5l8GgzvgHCPdGp1iUJQhNyKog==";
|
||||
// 判断是否为加密内容
|
||||
boolean isDataEncrypted = !content.startsWith("{");
|
||||
String decryptKey = "B_AES_KEY"; // 商家小程序 AES 密钥
|
||||
//AES密钥,这里参数不能写成固定的,开发阶段需传入模板的AES密钥,实例化后应传入商家小程序的AES密钥
|
||||
// 解密
|
||||
String plainData = null;
|
||||
if (isDataEncrypted) {
|
||||
try {
|
||||
System.out.println("AlipayEncrypt");
|
||||
plainData = AlipayEncrypt.decryptContent(content, encryptType, decryptKey,charset);
|
||||
System.out.println("AlipayEncrypt Trance done");
|
||||
} catch (AlipayApiException e) {
|
||||
//解密异常, 记录日志
|
||||
try {
|
||||
throw new Exception("解密异常");
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plainData = content;
|
||||
}
|
||||
System.out.println(plainData);
|
||||
public void decryptPhoneNum() throws Exception {
|
||||
|
||||
String content = "/CunEGSbDxsQaKllc35Q+4lJdLiprZhrHFt9er/ZriETVHv2IrtZsmC8cA6DE5l8GgzvgHCPdGp1iUJQhNyKog==";
|
||||
// 通过密文解密 获取手机号码
|
||||
String mobileNumber = Factory.Util.AES().decrypt(content);
|
||||
System.out.println(mobileNumber);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user