区块链调试
This commit is contained in:
@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@ -140,6 +141,7 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
List<CrypConfigure> list = this.list(query);
|
||||
|
||||
CrypConfigure crypConfigure = list.get(0);
|
||||
log.debug("秘钥:"+crypConfigure.getCValue());
|
||||
log.debug("加密参数:"+JSONArray.toJSONString(object));
|
||||
String signValue = CrypServiceImpl.signObject2(object,crypConfigure.getCValue());
|
||||
log.debug("加密结果:"+signValue);
|
||||
@ -208,8 +210,8 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
.eq(CrypConfigure::getCCode,"crt_key");
|
||||
|
||||
List<CrypConfigure> list = this.list(query);
|
||||
log.debug("---------获取解密秘钥--------");
|
||||
CrypConfigure crypConfigure = list.get(0);
|
||||
log.debug("解密秘钥:"+crypConfigure.getCValue());
|
||||
log.debug("解密参数:"+JSONArray.toJSONString(bean.getObject()));
|
||||
Boolean b = CrypServiceImpl.verifyValue(bean.getSign(),
|
||||
bean.getObject(),
|
||||
@ -221,4 +223,38 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String CRT_PATH = "D:\\工作\\联通\\代码\\3.0\\区块链\\数据签名生成程序\\adminNew.crt";
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, UnsupportedEncodingException {
|
||||
|
||||
// example of HashMap entity, treeMap can also work out,
|
||||
// but LinkedHashMap is NOT supported
|
||||
Map<String,Object> mapb= new HashMap<>();
|
||||
|
||||
Map<String,String> map = new HashMap<>(1);
|
||||
map.put("TENDERER_ID","8533");
|
||||
map.put("SHOPPINGCART_ID","L3307");
|
||||
map.put("AMOUNT","1000");
|
||||
map.put("TP_ID","L3307A");
|
||||
map.put("SECTION_ID","1111");
|
||||
|
||||
List list = new ArrayList();
|
||||
list.add(map);
|
||||
//mapb.put("BODY_LIST",list);
|
||||
|
||||
System.out.println(mapb);
|
||||
|
||||
String pkey = "-----BEGIN PRIVATE KEY-----\n" +
|
||||
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgfb0OcgWWFJGaOmVI\n" +
|
||||
"LxEpIRTsICs0ssgJZqpuZQUhTIGhRANCAAQ8dPtVEfZfm2wXdqoqYpColaJ4MxiJ\n" +
|
||||
"rFoUUMepAwuIQLaSZIH1+YbUkr/P+ybC1cbiBMrZjCxiAimk7dLxmUkx\n" +
|
||||
"-----END PRIVATE KEY-----";
|
||||
//"MEUCIQC0TNG+JlFa2kCwQOdYer69cA4psgDoK9ulqdKyK5BEwQIgFOlVofB+xDVOCSuj7t2Pp3z0fyyiuXPy5dRMsOMoh3U=";
|
||||
String signature = CrypServiceImpl.signObject2(list,pkey);
|
||||
System.out.println("signature of Map: "+signature);
|
||||
boolean isOk = CrypServiceImpl.verifyObject(signature,list,CRT_PATH);
|
||||
System.out.println("verify result of Map: "+ isOk);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user