EO指令新增通过索引去就行sm4加解密的接口
This commit is contained in:
@@ -36,7 +36,8 @@ public class TestAllMethods {
|
||||
public void before() {
|
||||
// 通过设置debug的属性开启debug,如果不设置则默认不打开
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
api = (SydApi4j) new SydApi4j().connect("172.16.18.59", 8889, null, 1000);
|
||||
// api = (SydApi4j) new SydApi4j().connect("172.16.18.59", 8889, null, 1000);
|
||||
api = (SydApi4j) new SydApi4j().connect("192.168.0.119", 8889, null, 1000);
|
||||
// api = (SydApi4j) new SydApi4j().connect("61.164.40.82", 8889, null, 1000);
|
||||
// api = (SydApi4j) new SydApi4j().connect("192.168.0.66", 8889, null, 1000);
|
||||
// api = (SydApi4j) new SydApi4j().connect("192.168.0.100", 8889, null, 1000);
|
||||
@@ -710,6 +711,7 @@ public class TestAllMethods {
|
||||
String key = "X6CEE744329499B426CEE744329499B42";
|
||||
String msg = "11111111111";
|
||||
byte[] bytes = api.SM4EncryptDataCBC(0, key, 0, 0 , msg.getBytes());
|
||||
System.out.println("输出为: " + Util.bytes2HexString(bytes));
|
||||
|
||||
byte[] bytes1 = api.SM4DecryptDataCBC(0, key, 0, 0, bytes);
|
||||
|
||||
@@ -803,6 +805,42 @@ public class TestAllMethods {
|
||||
System.out.println("明文:" + new String(bytes1));
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
// E0
|
||||
@Test
|
||||
public void testEncDecData1() {
|
||||
|
||||
// 000000000000011100000000001
|
||||
String key = "XK000000000000011100000000001";
|
||||
|
||||
String msg = "111111111111111111qewehtrhq1";
|
||||
|
||||
byte[] bytes = api.SYMEncryptDataCBC(1, key, msg.getBytes());
|
||||
|
||||
System.out.println("输出为: " + Util.bytes2HexString(bytes));
|
||||
|
||||
byte[] bytes1 = api.SYMDecryptDataCBC(1, key, bytes);
|
||||
System.out.println("明文:" + new String(bytes1));
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
// E0
|
||||
@Test
|
||||
public void testEncDecData2() {
|
||||
|
||||
String userId = "0000000000000111";
|
||||
String index = "00000001";
|
||||
|
||||
String msg = "1011111111111111101";
|
||||
|
||||
byte[] bytes = api.SYMSM4EncDataByIndex(0, userId, index, msg.getBytes());
|
||||
|
||||
System.out.println("输出为: " + Util.bytes2HexString(bytes));
|
||||
|
||||
byte[] bytes1 = api.SYMSM4DecDataByIndex(0, userId, index, bytes);
|
||||
System.out.println("明文:" + new String(bytes1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testaaa() throws UnsupportedEncodingException {
|
||||
String key = "X6CEE744329499B426CEE744329499B42";
|
||||
|
||||
Reference in New Issue
Block a user