添加大数据加密指令
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package cmbpoc;
|
||||
|
||||
import com.sunyard.proto.Util;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
public class FunctionTest {
|
||||
|
||||
private SydApi4j api;
|
||||
private String keypairIndex;
|
||||
private byte[] privateKey;
|
||||
private byte[] publicKey;
|
||||
private byte[] orgData;
|
||||
private String sign;
|
||||
|
||||
@Before
|
||||
public void start(){
|
||||
// 调试模式
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
|
||||
// 建立链接(单台)
|
||||
this.api = (SydApi4j) new SydApi4j().connect("192.168.0.100", 8889, null, 1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void stop(){
|
||||
if ( null != api ) {
|
||||
this.api.disconnect();
|
||||
this.api = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getPrivateKeyAndPublickKey(){
|
||||
this.publicKey = Util.hexString2Bytes(
|
||||
this.api.SM2GetPublicKeyC(keypairIndex)
|
||||
);
|
||||
|
||||
|
||||
this.privateKey = Util.hexString2Bytes(
|
||||
this.api.SM2GetPrivateKeyC(keypairIndex)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void SYD_SM2_Sign(){
|
||||
this.api.SYD_SM2_Sign_HA(1, privateKey, publicKey, orgData);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void SYD_SM2_Verify(){
|
||||
this.api.SYD_SM2_Verify_HA(1, publicKey, orgData, sign);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void SYD_SM2_Encrypt(){
|
||||
this.api.SM2Decrypt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user