增加验签的test
This commit is contained in:
parent
b0d113cceb
commit
58fefa9234
@ -3,11 +3,14 @@ package com.xhpc.order.intella;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import co.intella.crypto.AesCryptoUtil;
|
||||
import co.intella.crypto.KeyReader;
|
||||
import co.intella.crypto.RsaCryptoUtil;
|
||||
import co.intella.model.IntegratedRequestBody;
|
||||
import co.intella.model.RequestHeader;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.Base64;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -176,4 +179,24 @@ public class IntellaTest {
|
||||
System.out.println("--");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
private void check() throws Exception {
|
||||
String resp = "{\"MchId\":\"SLGtest\",\"MethodName\":\"支付寶(上海)\",\"Result\":\"0000\",\"StoreOrderNo\":\"99M5O22062800001\",\"TotalFee\":\"1\",\"Sign\":\"svfaNrblrL6MdoqdjLiNZTgYjC7C1WO1IKZAexvBwV0JzJvyFq5+gJ4ysZtvlopsQX0YSC1wFtWVW+jwzd0ltCBrmN/k/+VOOA5i1qdJZ3fGzCGaGto2TliVFhYuZrXLj3xA/z/kggCqQ5drsZu6Y4ss5AkRrsdpNAuX6EXjhIuwHVXz9j/TBKxLIHJG++DuhJiIyJf1osKsGU+YUsl9Ejf3mXmKXqPQomhyJNiBf6bOfK6ZObT1jwKVXfbKmcGDzRf9HSwuwRvJAaCQu+BVN7sc2O8Su5vsWVv/Ms6n1Uno44YES1jg7bqDxqoQghlAKoRs8/YhM3cxQqmgJiqOiw\\u003d\\u003d\"}";
|
||||
|
||||
|
||||
String sss = "{\"MchId\":\"SLGtest\",\"MethodName\":\"支付寶(上海)\",\"Result\":\"0000\",\"StoreOrderNo\":\"99M5O22062800001\",\"TotalFee\":\"1\"}";
|
||||
JSONObject respObject = JSON.parseObject(resp);
|
||||
String signStr = respObject.getString("Sign").replaceAll("\\u003d", "=");
|
||||
|
||||
Object object1 = respObject.remove("Sign");
|
||||
// String decodeStr = Base64.decodeStr(signStr);
|
||||
System.out.println(respObject);
|
||||
File der = new File("D:\\intella\\pub.der");
|
||||
InputStream is = new FileInputStream(der);
|
||||
PublicKey rsaPubKey = KeyReader.loadPublicKeyFromDER(is);
|
||||
boolean flag= RsaCryptoUtil.verify(Base64.decode(signStr), sss.getBytes(StandardCharsets.UTF_8), rsaPubKey);
|
||||
System.out.println(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user