Browse Source

[退款回调支持][整理]

release_toaliyun_real
Stormeye.Wu 7 years ago
parent
commit
d0ee69b1a3
3 changed files with 415 additions and 42 deletions
  1. +44
    -42
      mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java
  2. +312
    -0
      mallinkService/src/main/java/com/iformall/utils/Base64Util.java
  3. +59
    -0
      mallinkService/src/main/java/com/iformall/utils/CipherUtil.java

+ 44
- 42
mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java View File

@@ -20,6 +20,7 @@ import com.iformall.pay.WxRefundOrderSP;
import com.iformall.service.WxOrderService;
import com.iformall.service.WxRefundOrderService;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.CipherUtil;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;
import org.apache.commons.lang3.StringUtils;
@@ -689,60 +690,57 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
String partnerKey = payAccount.getApiKey();
try {
if (payWay == EnumPayWay.PAY_WAY_WEAPP) {
boolean signVerified = false;
// 微信支付
signVerified = WxPayment.verifyNotify(paramMap, partnerKey);
if (!signVerified) {
logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR);
}
if (!"SUCCESS".equals(paramMap.get("return_code"))) {
logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
logger.warn("notify refund, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单状态码非SUCCESS");
return XmlUtil.getRequestXml(resultMap);
}

String payOrderNo = paramMap.get("out_trade_no");
// 解密req_info
String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey);
Map<String, String> reqMap = WxPayment.xmlToMap(req_info);

String payOrderNo = reqMap.get("out_trade_no");
Long payOrderId = Long.valueOf(payOrderNo);
WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId);
if (payOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "支付订单不存在");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "支付订单总金额不一致");
return XmlUtil.getRequestXml(resultMap);
}
String refundIdStr = paramMap.get("out_refund_no");
String refundIdStr = reqMap.get("out_refund_no");
Long refundOrderId = Long.valueOf(refundIdStr);
WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId);
if (refundOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款订单不存在");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) {
logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单总金额不一致");
return XmlUtil.getRequestXml(resultMap);
}
// 验证退款金额
if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) {
logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) {
logger.warn("notify refund, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款总金额不一致");
@@ -750,16 +748,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
}

// 处理支付成功
handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id"));
logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id"));
logger.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "SUCCESS");
resultMap.put("return_msg", "OK");
return XmlUtil.getRequestXml(resultMap);
}
} catch (RuntimeException e) {
logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR);
logger.warn("notify refund paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage());
} catch (Exception e) {
logger.warn("notify refund, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage());
}
} else {
// 服务号回调
@@ -780,13 +781,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
String partnerKey = payAccount.getApiKey();
try {
if (payWay == EnumPayWay.PAY_WAY_WEAPP) {
boolean signVerified = false;
// 微信支付
signVerified = WxPayment.verifyNotifyHMAC(paramMap, partnerKey);
if (!signVerified) {
logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR);
}
if (!"SUCCESS".equals(paramMap.get("return_code"))) {
logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
@@ -795,7 +789,12 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
return XmlUtil.getRequestXml(resultMap);
}

String payOrderNo = paramMap.get("out_trade_no");
// 解密req_info
String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey);
logger.info(req_info);
Map<String, String> reqMap = WxPayment.xmlToMap(req_info);

String payOrderNo = reqMap.get("out_trade_no");
if (payOrderNo == null) {
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "SUCCESS");
@@ -805,41 +804,41 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
Long payOrderId = Long.valueOf(payOrderNo);
WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId);
if (payOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "支付订单不存在");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "支付订单总金额不一致");
return XmlUtil.getRequestXml(resultMap);
}
String refundIdStr = paramMap.get("out_refund_no");
String refundIdStr = reqMap.get("out_refund_no");
Long refundOrderId = Long.valueOf(refundIdStr);
WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId);
if (refundOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款订单不存在");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) {
logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单总金额不一致");
return XmlUtil.getRequestXml(resultMap);
}
// 验证退款金额
if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) {
logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
if(!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) {
logger.warn("notify refund, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款总金额不一致");
@@ -847,16 +846,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
}

// 处理支付成功
handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id"));
logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id"));
logger.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: "+reqMap.toString()+ ", payWay:" + payWay.toString());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "SUCCESS");
resultMap.put("return_msg", "OK");
return XmlUtil.getRequestXml(resultMap);
}
} catch (RuntimeException e) {
logger.warn("notify order, wepay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
logger.warn("notify refund, wepay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR);
} catch (Exception e) {
logger.warn("notify refund, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage());
}
}



+ 312
- 0
mallinkService/src/main/java/com/iformall/utils/Base64Util.java View File

@@ -0,0 +1,312 @@
package com.iformall.utils;

import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

public class Base64Util {
private static final char S_BASE64CHAR[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' };
private static final byte S_DECODETABLE[];

static {
S_DECODETABLE = new byte[128];
for (int i = 0; i < S_DECODETABLE.length; i++)
S_DECODETABLE[i] = 127;

for (int i = 0; i < S_BASE64CHAR.length; i++)
S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;

}

/**
*
* @param ibuf
* @param obuf
* @param wp
* @return
*/
private static int decode0(char ibuf[], byte obuf[], int wp) {
int outlen = 3;
if (ibuf[3] == '=')
outlen = 2;
if (ibuf[2] == '=')
outlen = 1;
int b0 = S_DECODETABLE[ibuf[0]];
int b1 = S_DECODETABLE[ibuf[1]];
int b2 = S_DECODETABLE[ibuf[2]];
int b3 = S_DECODETABLE[ibuf[3]];
switch (outlen) {
case 1: // '\001'
obuf[wp] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3);
return 1;

case 2: // '\002'
obuf[wp++] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3);
obuf[wp] = (byte) (b1 << 4 & 240 | b2 >> 2 & 15);
return 2;

case 3: // '\003'
obuf[wp++] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3);
obuf[wp++] = (byte) (b1 << 4 & 240 | b2 >> 2 & 15);
obuf[wp] = (byte) (b2 << 6 & 192 | b3 & 63);
return 3;
}
throw new RuntimeException("Internal error");
}

/**
*
* @param data
* @param off
* @param len
* @return
*/
public static byte[] decode(char data[], int off, int len) {
char ibuf[] = new char[4];
int ibufcount = 0;
byte obuf[] = new byte[(len / 4) * 3 + 3];
int obufcount = 0;
for (int i = off; i < off + len; i++) {
char ch = data[i];
if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127))
continue;
ibuf[ibufcount++] = ch;
if (ibufcount == ibuf.length) {
ibufcount = 0;
obufcount += decode0(ibuf, obuf, obufcount);
}
}

if (obufcount == obuf.length) {
return obuf;
}
else {
byte ret[] = new byte[obufcount];
System.arraycopy(obuf, 0, ret, 0, obufcount);
return ret;
}
}

/**
*
* @param data
* @return
*/
public static byte[] decode(String data) {
char ibuf[] = new char[4];
int ibufcount = 0;
byte obuf[] = new byte[(data.length() / 4) * 3 + 3];
int obufcount = 0;
for (int i = 0; i < data.length(); i++) {
char ch = data.charAt(i);
if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127))
continue;
ibuf[ibufcount++] = ch;
if (ibufcount == ibuf.length) {
ibufcount = 0;
obufcount += decode0(ibuf, obuf, obufcount);
}
}

if (obufcount == obuf.length) {
return obuf;
}
else {
byte ret[] = new byte[obufcount];
System.arraycopy(obuf, 0, ret, 0, obufcount);
return ret;
}
}

/**
*
* @param data
* @param off
* @param len
* @param ostream
* @throws IOException
*/
public static void decode(char data[], int off, int len, OutputStream ostream) throws IOException {
char ibuf[] = new char[4];
int ibufcount = 0;
byte obuf[] = new byte[3];
for (int i = off; i < off + len; i++) {
char ch = data[i];
if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127))
continue;
ibuf[ibufcount++] = ch;
if (ibufcount == ibuf.length) {
ibufcount = 0;
int obufcount = decode0(ibuf, obuf, 0);
ostream.write(obuf, 0, obufcount);
}
}

}

/**
*
* @param data
* @param ostream
* @throws IOException
*/
public static void decode(String data, OutputStream ostream) throws IOException {
char ibuf[] = new char[4];
int ibufcount = 0;
byte obuf[] = new byte[3];
for (int i = 0; i < data.length(); i++) {
char ch = data.charAt(i);
if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127))
continue;
ibuf[ibufcount++] = ch;
if (ibufcount == ibuf.length) {
ibufcount = 0;
int obufcount = decode0(ibuf, obuf, 0);
ostream.write(obuf, 0, obufcount);
}
}

}

/**
*
* @param data
* @return
*/
public static String encode(byte data[]) {
return encode(data, 0, data.length);
}

/**
*
* @param data
* @param off
* @param len
* @return
*/
public static String encode(byte data[], int off, int len) {
if (len <= 0)
return "";
char out[] = new char[(len / 3) * 4 + 4];
int rindex = off;
int windex = 0;
int rest;
for (rest = len - off; rest >= 3; rest -= 3) {
int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255);
out[windex++] = S_BASE64CHAR[i >> 18];
out[windex++] = S_BASE64CHAR[i >> 12 & 63];
out[windex++] = S_BASE64CHAR[i >> 6 & 63];
out[windex++] = S_BASE64CHAR[i & 63];
rindex += 3;
}

if (rest == 1) {
int i = data[rindex] & 255;
out[windex++] = S_BASE64CHAR[i >> 2];
out[windex++] = S_BASE64CHAR[i << 4 & 63];
out[windex++] = '=';
out[windex++] = '=';
}
else if (rest == 2) {
int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255);
out[windex++] = S_BASE64CHAR[i >> 10];
out[windex++] = S_BASE64CHAR[i >> 4 & 63];
out[windex++] = S_BASE64CHAR[i << 2 & 63];
out[windex++] = '=';
}
return new String(out, 0, windex);
}

/**
*
* @param data
* @param off
* @param len
* @param ostream
* @throws IOException
*/
public static void encode(byte data[], int off, int len, OutputStream ostream) throws IOException {
if (len <= 0)
return;
byte out[] = new byte[4];
int rindex = off;
int rest;
for (rest = len - off; rest >= 3; rest -= 3) {
int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255);
out[0] = (byte) S_BASE64CHAR[i >> 18];
out[1] = (byte) S_BASE64CHAR[i >> 12 & 63];
out[2] = (byte) S_BASE64CHAR[i >> 6 & 63];
out[3] = (byte) S_BASE64CHAR[i & 63];
ostream.write(out, 0, 4);
rindex += 3;
}

if (rest == 1) {
int i = data[rindex] & 255;
out[0] = (byte) S_BASE64CHAR[i >> 2];
out[1] = (byte) S_BASE64CHAR[i << 4 & 63];
out[2] = 61;
out[3] = 61;
ostream.write(out, 0, 4);
}
else if (rest == 2) {
int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255);
out[0] = (byte) S_BASE64CHAR[i >> 10];
out[1] = (byte) S_BASE64CHAR[i >> 4 & 63];
out[2] = (byte) S_BASE64CHAR[i << 2 & 63];
out[3] = 61;
ostream.write(out, 0, 4);
}
}

/**
*
* @param data
* @param off
* @param len
* @param writer
* @throws IOException
*/
public static void encode(byte data[], int off, int len, Writer writer) throws IOException {
if (len <= 0)
return;
char out[] = new char[4];
int rindex = off;
int rest = len - off;
int output = 0;
do {
if (rest < 3)
break;
int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255);
out[0] = S_BASE64CHAR[i >> 18];
out[1] = S_BASE64CHAR[i >> 12 & 63];
out[2] = S_BASE64CHAR[i >> 6 & 63];
out[3] = S_BASE64CHAR[i & 63];
writer.write(out, 0, 4);
rindex += 3;
rest -= 3;
if ((output += 4) % 76 == 0)
writer.write("\n");
}
while (true);
if (rest == 1) {
int i = data[rindex] & 255;
out[0] = S_BASE64CHAR[i >> 2];
out[1] = S_BASE64CHAR[i << 4 & 63];
out[2] = '=';
out[3] = '=';
writer.write(out, 0, 4);
}
else if (rest == 2) {
int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255);
out[0] = S_BASE64CHAR[i >> 10];
out[1] = S_BASE64CHAR[i >> 4 & 63];
out[2] = S_BASE64CHAR[i << 2 & 63];
out[3] = '=';
writer.write(out, 0, 4);
}
}

}

+ 59
- 0
mallinkService/src/main/java/com/iformall/utils/CipherUtil.java View File

@@ -0,0 +1,59 @@
package com.iformall.utils;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.security.Security;

public class CipherUtil {

/**
* 密钥算法
*/
private static final String ALGORITHM = "AES";
/**
* 加解密算法/工作模式/填充方式
*/
private static final String ALGORITHM_MODE_PADDING = "AES/ECB/PKCS7Padding";

static {
try {
Security.addProvider(new BouncyCastleProvider());
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* AES解密
*/
public static String decryptData(byte[] b, String serectKey) throws Exception {
Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
SecretKeySpec key = new SecretKeySpec(HashUtil.md5(serectKey).toLowerCase().getBytes(), ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, key);
return new String(cipher.doFinal(b));
}

/**
* decryptReqInfo
* @param req_info
* @param key
* @return
* @throws Exception
*/
public static String decryptReqInfo(String req_info, String key) throws Exception {
byte[] b = Base64Util.decode(req_info);
String B = decryptData(b, key);
return B;
}



public static void main(String[] args) throws Exception {

String A = "Ndaz8Fj4VUkxnD9iQ2ghD8yRgG8M9gBa0qIP4/GebJtzFWswbquDH/+kX3ZGB6zVb//4ZLIxMC4IZ0hzhsNc8JsDGbPKSYlaBI1prdbXr8YMzqAAHg+UJKNPyibJAV0o+soGNYeVrzVhzjWk0oFzCk2rvAtLlnq6RKjwTLOlIUxWXJMvtsCtpXKvcWMxRx+8pn42Barx6B2D0lM+39Vmi5Mu6XXHi9xUO+KPF7sgfv4hz/2NBBBfsR9Df0CxfQrEKmjxWgrl4Cn1g8JvBhZJiqUsP0oxS+xBZVGRLRY66oDNaLlNtzmwsrkEnDc1hWXgy3AymB0oLRz5SAOry0vKrzqv/yw1pWzyltAZ/M7ge6iD7gP/ILcxty5HjOZE22p01J6MqW8UAiTizrURucC/e3f9N935qs3DR8oqDO2Di4KR1pZnVQcxStnrlnq5YkaZRYXAdp3od80zCaNnNKxWuygxbJwkLOeohVaZNaCrBtxtvzZgHHiIrXSjAtHhXdxcl3A7Oo7M2I11D7Sss/BF72W8b0VgLY/GeJvUI5cmxpjMsE445coq7FQpAGZiLzohg73VpTA2GLxkev0xZj22XdKuJpl4SIOaSBxnDLTILzs/Ed6BndL3+jeep3eb2i5GbzREkdBlHUqxr7/ea9OeMZLVnLcWPmcDctDEQGObVQOlLD9KMUvsQWVRkS0WOuqAkQXAqvB5qhA48BZlHAitz7F2Q4+aAJx5KUFIkrxpYNMuoAvUBRA4HNaQz/metEA10EzVcTsuG2OCQmHsVIRqhMgbRz3a3xjTWMxN1KoHO8KaxEdN3CpXfXSNgMvEa/G4v6As59RnW5PRxUeqJSyfgMeoACdLb6tGwk8Jd72NPP8HMF4fUy8JqgtoOcm6UTBdcQHb/OVqQSDpWlNToOB9GdBM1XE7LhtjgkJh7FSEaoQ576jMlCjyCAqd+c3yiDBIrtaemJwBBhwHmnHMwYimTSDDzy4mbTZE41svWepZKmZcH/6+OM+d71UOiPaVQS6IJZhBCvKYLpbpu4+OjEUNGKE+8CpN5TcxfpQLR+6c/KZZjXSTeR4RK6I2yNW7yocy";
String B = decryptReqInfo(A, "XHZfpVA0NzoXgLEjsujctUTcyj8Zur2C");
System.out.println(B);
}
}

Loading…
Cancel
Save