Commit 36041958 authored by qinxunjia's avatar qinxunjia

生产参数配置

parent 7cbc29fa
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>dmhub-plugin</artifactId> <artifactId>dmhub-plugin</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0.0</version>
<name>插件服务</name> <name>插件服务</name>
<description>DM hub集成插件服务</description> <description>DM hub集成插件服务</description>
......
package com.bgy.util;
import com.alibaba.fastjson.JSONObject;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class CryptoUtils {
private AlgorithmParameterSpec iv;
private Key key;
public CryptoUtils(String _DESkey, String _vi) throws Exception {
DESedeKeySpec keySpec = new DESedeKeySpec(_DESkey.getBytes(StandardCharsets.UTF_8));
iv = new IvParameterSpec(_vi.getBytes(StandardCharsets.UTF_8));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("desede");
key = keyFactory.generateSecret(keySpec);
}
public static void main(String[] args) throws Exception {
Map<String, String> querMap = new HashMap<>();
querMap.put("bipid", "888");
CryptoUtils des = new CryptoUtils("BF7834FA210A407BA449A2B8", "BD162758");
String encodeParam = des.encode(Objects.requireNonNull(JSONObject.toJSONString(querMap)));
Map<String, String> paramMap = new HashMap<>();
paramMap.put("package", encodeParam);
paramMap.put("companyid", "3C877D40-DCB1-4304-AC50-242E032A761A");
paramMap.put("channelid", "FHYMA");
String retStr = HttpUtil.sendPost("https://xstest.bgy.com.cn/ApiBgyTest/MerchantAlliance/GetAccountLimit", JSONObject.toJSONString(paramMap));
String test = "{\"bipId\":\"shenxiang11\"}";
JSONObject retJson = JSONObject.parseObject(retStr);
String packageInfo = retJson.getString("package");
String decode = des.decode(packageInfo);
System.out.println("" + test);
System.out.println("" + des.encode(test));
System.out.println("" + des.decode(des.encode(test)));
}
/**
* CBC加密
*
* @return Base64编码的密文
*/
public String encode(String data) throws Exception {
Cipher enCipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
enCipher.init(Cipher.ENCRYPT_MODE, key, iv);
byte[] pasByte = enCipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
return Base64.getEncoder().encodeToString(pasByte);
}
/**
* CBC解密
*
* @return 明文
*/
public String decode(String data) throws Exception {
Cipher deCipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
deCipher.init(Cipher.DECRYPT_MODE, key, iv);
byte[] pasByte = deCipher.doFinal(Base64.getDecoder().decode(data));
return new String(pasByte, StandardCharsets.UTF_8);
}
}
\ No newline at end of file
...@@ -22,7 +22,6 @@ spring: ...@@ -22,7 +22,6 @@ spring:
idleTimeout: 600000 idleTimeout: 600000
pool-name: dmhub-plug-pool pool-name: dmhub-plug-pool
redis: redis:
database: 0 database: 0
host: rs67xf4p.redisrep.db.pcloud.localdomain host: rs67xf4p.redisrep.db.pcloud.localdomain
...@@ -37,10 +36,10 @@ system: ...@@ -37,10 +36,10 @@ system:
areaId: XXJSB areaId: XXJSB
api: SendSms api: SendSms
dmHub: dmHub:
applicationId: cl0300171a6012c21 applicationId: cl016b172dab13e2b
applicationKey: 4017078e9dfd593b2d9a0ede58eff589644fbe50 applicationKey: 834f5758ce3ab9d9c01b80e6d0a51ff3dda48bd3
tokenUrl: https://api.convertlab.com/security/accesstoken tokenUrl: https://api-xscdp.bgy.com.cn/security/accesstoken
report: https://api.convertlab.com/v1/sms/report report: https://api-xscdp.bgy.com.cn/v1/sms/report
appId: 1smsdemo appId: 1smsdemo
appSecret: ac031765c3a8c9acc4747808e4fe5918 appSecret: ac031765c3a8c9acc4747808e4fe5918
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment