删除控制台打印
This commit is contained in:
parent
3a0afa946d
commit
9ccab48de8
@ -83,7 +83,6 @@ public class BytesQueue {
|
||||
}
|
||||
|
||||
int hasLen = q.length - index;
|
||||
System.out.println(String.format("-> %d %d %d", dataIndex, needLen, hasLen));
|
||||
if ( hasLen == needLen ) {
|
||||
System.arraycopy( q, index , data, dataIndex, needLen );
|
||||
it.remove();
|
||||
|
||||
@ -108,9 +108,6 @@ public class SydSM4Backup implements ISM4 {
|
||||
nSourceWrap.put( waitData );
|
||||
nSourceWrap.put( pcData );
|
||||
sourceWrap = nSourceWrap;
|
||||
|
||||
System.out.println("new sourceWrap=" + Util.bytes2HexString(sourceWrap.array()));
|
||||
|
||||
int totalLen = sourceWrap.array().length;
|
||||
if ( totalLen / 16 < 2){
|
||||
return new byte[0];
|
||||
@ -128,21 +125,7 @@ public class SydSM4Backup implements ISM4 {
|
||||
byte[] waitBuff = new byte[ totalLen - sendBuffLen ];
|
||||
sourceWrap.get( waitBuff , 0, waitBuff.length );
|
||||
|
||||
System.out.println( String.format("debug inDataLen=%d totalDataLen=%d sendDataLen=%d 16=%d iPkgNum=%d",
|
||||
pcData.length,
|
||||
totalLen,
|
||||
sendBuff.length,
|
||||
sendBuff.length % 16,
|
||||
iPkgNum)
|
||||
);
|
||||
|
||||
System.out.println( "waitBuff=" + Util.bytes2HexString( waitBuff ) );
|
||||
|
||||
if( 0x00 == waitBuff[0] ) {
|
||||
System.out.println("eee");
|
||||
}
|
||||
sourceWrap = ByteBuffer.wrap( waitBuff );
|
||||
System.out.println("sourceWrap=" + Util.bytes2HexString(sourceWrap.array()));
|
||||
byte[] bytes2 = api.SYD_SM4_LongData(iKeyIndex, sendBuff, iPkgNum, iFlag);
|
||||
|
||||
iPkgNum = 2;
|
||||
|
||||
@ -22,7 +22,6 @@ public class ConnectThread extends Thread {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(Thread.currentThread().getName() + "已运行");
|
||||
ConnectThread stable = new ConnectThread();
|
||||
SydApi api = stable.getApi();
|
||||
try {
|
||||
|
||||
@ -65,7 +65,6 @@ public class Sample
|
||||
if ( null != api ) {
|
||||
api.SYD_Disconnect_Ex();
|
||||
}
|
||||
System.out.println("all over");
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +123,6 @@ public class Sample
|
||||
|
||||
byte[] enData = new byte[ enDataBuff.position() ];
|
||||
System.arraycopy( enDataBuff.array(), 0, enData, 0, enData.length );
|
||||
System.out.println( "EnData HEX=" + Util.bytes2HexString( enData ));
|
||||
|
||||
|
||||
// 分包解密
|
||||
@ -169,8 +167,6 @@ public class Sample
|
||||
|
||||
byte[] deData = new byte[ deDataBuff.position() ];
|
||||
System.arraycopy( deDataBuff.array(), 0, deData, 0, deData.length );
|
||||
System.out.println( "DeData HEX=" + Util.bytes2HexString( deData ));
|
||||
|
||||
// 断言解密后和原文相同
|
||||
Assert.assertArrayEquals( deData, data );
|
||||
}
|
||||
@ -224,8 +220,6 @@ public class Sample
|
||||
}
|
||||
|
||||
String mac = recv.getData();
|
||||
System.out.println( "MAC=" + mac);
|
||||
|
||||
|
||||
// 分包校验 MAC
|
||||
LongDataReturn<String, Boolean> check = null;
|
||||
@ -273,7 +267,6 @@ public class Sample
|
||||
// 测试数据
|
||||
byte[] data = new byte[16];
|
||||
String macData = api.SYD_SM3_Hash_ShortData( data );
|
||||
System.out.println( "SM3=" + macData );
|
||||
Assert.assertEquals( macData , "106E34A2B8C7BB13156CFDD0D91379DCC47543DCF9787C68AE5EB582620AE6E8");
|
||||
}
|
||||
|
||||
@ -326,7 +319,6 @@ public class Sample
|
||||
}
|
||||
|
||||
String mac = recv.getData();
|
||||
System.out.println( "SM3=" + mac);
|
||||
|
||||
// 断言
|
||||
Assert.assertEquals( mac, "87B81AF2B2B22CBDF268E211D012D604892D3C948FF298D61D6C942EEE847F86");
|
||||
@ -338,7 +330,6 @@ public class Sample
|
||||
// 测试数据
|
||||
byte[] data = new byte[16];
|
||||
String macData = api.SYD_SM4Mac_ShortData( keyIdx , data );
|
||||
System.out.println( "MAC=" + macData );
|
||||
boolean ret = api.SYD_SM4Mac_ShortData( keyIdx , data, macData );
|
||||
Assert.assertTrue( ret );
|
||||
}
|
||||
@ -356,7 +347,6 @@ public class Sample
|
||||
boolean[] checks = api.SYD_SM4Mac_BatchData( keyIdx , data, macs );
|
||||
|
||||
for ( int i = 0 ; i < data.size() ; i++ ) {
|
||||
System.out.println( "MAC["+ i +"]=" + macs[i] );
|
||||
Assert.assertTrue( checks[i] );
|
||||
}
|
||||
}
|
||||
@ -369,7 +359,6 @@ public class Sample
|
||||
byte[] data = new byte[16];
|
||||
byte[] encData = api.SYD_SM4_ShortData( keyIdx , data, Consts.ECB_ENC );
|
||||
byte[] orgData = api.SYD_SM4_ShortData( keyIdx , encData, Consts.ECB_DEC );
|
||||
System.out.println( "HEX=" + Util.bytes2HexString( encData ) );
|
||||
Assert.assertArrayEquals( orgData, data );
|
||||
}
|
||||
|
||||
@ -386,7 +375,6 @@ public class Sample
|
||||
List<byte[]> orgData = api.SYD_SM4_BatchData( keyIdx , encData, Consts.ECB_DEC );
|
||||
|
||||
for ( int i = 0 ; i < data.size() ; i++ ) {
|
||||
System.out.println( "HEX=" + Util.bytes2HexString( encData.get( i ) ) );
|
||||
Assert.assertArrayEquals( orgData.get( i ), data.get( i ) );
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,6 @@ public class BatchDataTest {
|
||||
List<byte[]> orgData = api.SYD_SM4_BatchData(keyIdx, encData, Consts.ECB_DEC);
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
System.out.println("HEX=" + Util.bytes2HexString(encData.get(i)));
|
||||
Assert.assertArrayEquals(orgData.get(i), data.get(i));
|
||||
}
|
||||
}
|
||||
@ -114,7 +113,6 @@ public class BatchDataTest {
|
||||
List<byte[]> orgData = api.SYD_SM4_BatchData(data.getKeyIdx(), encData, Consts.ECB_DEC);
|
||||
|
||||
for (int i = 0; i < data.getSize(); i++) {
|
||||
System.out.println("HEX=" + Util.bytes2HexString(encData.get(i)));
|
||||
Assert.assertArrayEquals(orgData.get(i), data.getData().get(i));
|
||||
}
|
||||
}
|
||||
@ -128,7 +126,6 @@ public class BatchDataTest {
|
||||
List<byte[]> orgData = api.SYD_SM4_BatchData(data.getKeyIdx(), encData, Consts.ECB_DEC);
|
||||
|
||||
for (int i = 0; i < data.getSize(); i++) {
|
||||
System.out.println("HEX=" + Util.bytes2HexString(encData.get(i)));
|
||||
Assert.assertArrayEquals(orgData.get(i), data.getData().get(i));
|
||||
}
|
||||
}
|
||||
@ -156,7 +153,6 @@ public class BatchDataTest {
|
||||
boolean[] checks = api.SYD_SM4Mac_BatchData(keyIdx, data, macs);
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
System.out.println("MAC[" + i + "]=" + macs[i]);
|
||||
Assert.assertTrue(checks[i]);
|
||||
}
|
||||
}
|
||||
@ -170,7 +166,6 @@ public class BatchDataTest {
|
||||
boolean[] checks = api.SYD_SM4Mac_BatchData(data.getKeyIdx(), data.getData(), macs);
|
||||
|
||||
for (int i = 0; i < data.getSize(); i++) {
|
||||
System.out.println("MAC[" + i + "]=" + macs[i]);
|
||||
Assert.assertTrue(checks[i]);
|
||||
}
|
||||
}
|
||||
@ -184,7 +179,6 @@ public class BatchDataTest {
|
||||
boolean[] checks = api.SYD_SM4Mac_BatchData(data.getKeyIdx(), data.getData(), macs);
|
||||
|
||||
for (int i = 0; i < data.getSize(); i++) {
|
||||
System.out.println("MAC[" + i + "]=" + macs[i]);
|
||||
Assert.assertTrue(checks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,5 @@ public class ByteBuffTest {
|
||||
b2.put( bb );
|
||||
|
||||
|
||||
System.out.println( b2.position() );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,6 @@ public class FuncTest {
|
||||
for (int j = 0; j < 20; j++) {
|
||||
byte[] bytes = api.SYD_SM4_ShortData(0, (tmp + "t" + j).getBytes(), Consts.ECB_ENC);
|
||||
byte[] result = api.SYD_SM4_ShortData(0, bytes, Consts.ECB_DEC);
|
||||
System.out.println(Thread.currentThread().getName() + "," + new String(result));
|
||||
}
|
||||
}, i + "t").start();
|
||||
}
|
||||
@ -81,7 +80,6 @@ public class FuncTest {
|
||||
api.SYD_Short_Connect_Ex(pcipList,iportList,10,15);
|
||||
byte[] bytes = api.SYD_SM4_ShortData(0, (tmp + "t" + j).getBytes(), Consts.ECB_ENC);
|
||||
byte[] result = api.SYD_SM4_ShortData(0, bytes, Consts.ECB_DEC);
|
||||
System.out.println(Thread.currentThread().getName() + "," + new String(result));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@ -22,9 +22,7 @@ public class FutureTaskTest {
|
||||
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
System.out.println( Thread.currentThread() + " task start");
|
||||
Thread.sleep( 1000 );
|
||||
System.out.println( Thread.currentThread() + " task over");
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
@ -33,9 +31,7 @@ public class FutureTaskTest {
|
||||
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
System.out.println( Thread.currentThread() + " task start");
|
||||
Thread.sleep( 2000 );
|
||||
System.out.println( Thread.currentThread() + " task over");
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
@ -44,9 +40,7 @@ public class FutureTaskTest {
|
||||
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
System.out.println( Thread.currentThread() + " task start");
|
||||
Thread.sleep( 3000 );
|
||||
System.out.println( Thread.currentThread() + " task over");
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
@ -59,7 +53,6 @@ public class FutureTaskTest {
|
||||
|
||||
long endAt = System.currentTimeMillis();
|
||||
|
||||
System.out.println("耗时 " + ( endAt - startAt ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,15 +54,11 @@ public class LengthTest
|
||||
|
||||
// 解密 pcData长度为0
|
||||
List<byte[]> orgDatas = api.SYD_SM4_BatchData( keyIdx , data, Consts.ECB_DEC );
|
||||
for (byte[] byte_1 :orgDatas) {
|
||||
System.out.printf("解密后数据", Arrays.toString(byte_1));
|
||||
}
|
||||
|
||||
//解密 pcData长度不为0
|
||||
List<byte[]> encData = api.SYD_SM4_BatchData( keyIdx , data2, Consts.ECB_ENC );
|
||||
List<byte[]> orgDatas2 = api.SYD_SM4_BatchData( keyIdx , encData, Consts.ECB_DEC );
|
||||
for (byte[] byte_2 :orgDatas2) {
|
||||
System.out.println(Arrays.toString(byte_2));
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void syd_SM4_LongDataTest(){
|
||||
@ -74,7 +70,6 @@ public class LengthTest
|
||||
int pack = 16;
|
||||
//解密 pcData长度为0
|
||||
byte[] recv = api.SYD_SM4_LongData( keyIdx , new byte[0], Consts.PkgNumHead, Consts.ECB_DEC);
|
||||
System.out.println(Arrays.toString(recv));
|
||||
//解密 pcData长度不为0
|
||||
// 密文数据
|
||||
ByteBuffer enDataBuff = ByteBuffer.allocate( data.length + 16 );
|
||||
@ -115,8 +110,6 @@ public class LengthTest
|
||||
}
|
||||
byte[] enData = new byte[ enDataBuff.position() ];
|
||||
System.arraycopy( enDataBuff.array(), 0, enData, 0, enData.length );
|
||||
System.out.println( "EnData HEX=" + Util.bytes2HexString( enData ));
|
||||
|
||||
|
||||
// 分包解密
|
||||
// 密文数据
|
||||
@ -158,7 +151,6 @@ public class LengthTest
|
||||
}
|
||||
byte[] deData = new byte[ deDataBuff.position() ];
|
||||
System.arraycopy( deDataBuff.array(), 0, deData, 0, deData.length );
|
||||
System.out.println( "DeData HEX=" + Util.bytes2HexString( deData ));
|
||||
|
||||
// 断言解密后和原文相同
|
||||
Assert.assertArrayEquals( deData, data );
|
||||
|
||||
@ -31,13 +31,9 @@ public class LogTest {
|
||||
}
|
||||
|
||||
Thread.sleep(10000 );
|
||||
System.out.println("over");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(new byte[0].length);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -56,18 +56,14 @@ public class LongDataTest {
|
||||
@Test
|
||||
public void sm3_case4() {
|
||||
ISM3 sm3 = api.initSM3();
|
||||
System.out.print("org=");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
int lucky = new Random().nextInt(4065);
|
||||
byte[] data = new byte[lucky];
|
||||
new Random().nextBytes(data);
|
||||
System.out.print(Util.bytes2HexString(data));
|
||||
sm3.update(data);
|
||||
}
|
||||
|
||||
String mac = sm3.digest();
|
||||
System.out.println();
|
||||
System.out.println(mac);
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +100,7 @@ public class LongDataTest {
|
||||
}
|
||||
|
||||
String mac = (String) sydApiMac.disget();
|
||||
System.out.println(mac);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +108,6 @@ public class LongDataTest {
|
||||
public void case5() {
|
||||
ISM4 sydApiSM4 = api.initSM4(1, 1);
|
||||
byte[] enData = sydApiSM4.finish();
|
||||
System.out.println(Util.bytes2HexString(enData));
|
||||
Assert.assertArrayEquals(Util.hexString2Bytes("FF49F76AD3A71651FE1A8A9F0D2A689E"), enData);
|
||||
}
|
||||
|
||||
@ -123,14 +118,12 @@ public class LongDataTest {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int lucky = new Random().nextInt(4065);
|
||||
byte[] data = new byte[lucky];
|
||||
System.out.println("len=" + lucky);
|
||||
|
||||
new Random().nextBytes(data);
|
||||
sydApiSM4.update(data);
|
||||
}
|
||||
|
||||
byte[] enData = sydApiSM4.finish();
|
||||
System.out.println(Util.bytes2HexString(enData));
|
||||
}
|
||||
|
||||
|
||||
@ -151,15 +144,11 @@ public class LongDataTest {
|
||||
int lucky = new Random().nextInt(size);
|
||||
byte[] data = new byte[lucky];
|
||||
inData.put(data);
|
||||
System.out.println("in=" + data.length);
|
||||
enData.put(en.update(data));
|
||||
}
|
||||
byte[] v = en.finish();
|
||||
System.out.println("finish=" + v.length);
|
||||
enData.put(v);
|
||||
|
||||
System.out.println("原文=" + inData.position());
|
||||
System.out.println("密文=" + enData.position());
|
||||
|
||||
if (1 == max) {
|
||||
|
||||
@ -167,18 +156,14 @@ public class LongDataTest {
|
||||
System.arraycopy(inData.array(), 0, in, 0, in.length);
|
||||
|
||||
byte[] bytes = api.SYD_SM4_ShortData(1, in, Consts.ECB_ENC);
|
||||
System.out.println("对比 =" + Util.bytes2HexString(bytes));
|
||||
|
||||
|
||||
byte[] look = new byte[enData.position()];
|
||||
System.arraycopy(enData.array(), 0, look, 0, look.length);
|
||||
System.out.println(Util.bytes2HexString(look));
|
||||
|
||||
System.out.println("eq=" + Arrays.equals(look, bytes));
|
||||
|
||||
|
||||
byte[] deBytes = api.SYD_SM4_ShortData(1, bytes, Consts.ECB_DEC);
|
||||
System.out.println("还原=" + Util.bytes2HexString(deBytes));
|
||||
|
||||
}
|
||||
|
||||
@ -191,7 +176,6 @@ public class LongDataTest {
|
||||
deData.put(de.update(data));
|
||||
while (true) {
|
||||
int lucky = new Random().nextInt(size);
|
||||
System.out.println("lucky=" + lucky);
|
||||
data = new byte[lucky];
|
||||
|
||||
if (enData.position() + lucky >= enData.limit()) {
|
||||
|
||||
@ -48,14 +48,11 @@ public class PrefTest {
|
||||
long st = System.currentTimeMillis();
|
||||
shortData(api);
|
||||
long et = System.currentTimeMillis();
|
||||
System.out.println("short t1=" + (et - st));
|
||||
|
||||
|
||||
// 批量
|
||||
st = System.currentTimeMillis();
|
||||
batchData(api);
|
||||
et = System.currentTimeMillis();
|
||||
System.out.println("batch t1=" + (et - st));
|
||||
}
|
||||
});
|
||||
|
||||
@ -70,13 +67,10 @@ public class PrefTest {
|
||||
long st = System.currentTimeMillis();
|
||||
shortData(api);
|
||||
long et = System.currentTimeMillis();
|
||||
System.out.println("short t1=" + (et - st));
|
||||
|
||||
// 批量
|
||||
st = System.currentTimeMillis();
|
||||
batchData(api);
|
||||
et = System.currentTimeMillis();
|
||||
System.out.println("batch t1=" + (et - st));
|
||||
} finally {
|
||||
if (null != api) {
|
||||
api.SYD_Disconnect_Ex();
|
||||
@ -115,7 +109,6 @@ public class PrefTest {
|
||||
List<byte[]> orgData = api.SYD_SM4_BatchData(keyIdx, encData, Consts.ECB_DEC);
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
System.out.println("HEX=" + Util.bytes2HexString(encData.get(i)));
|
||||
Assert.assertArrayEquals(orgData.get(i), data.get(i));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user