增加测试sm4的代码

This commit is contained in:
free will committed 2021-07-23 10:27:13 +08:00
1 parent 5713f05a6c
commit 78be6db12c
1 file changed
+34
@@ -0,0 +1,34 @@
package VMSConnection.Security;
import VMSConnection.Security.SM4.BC_SM4;
import org.junit.Test;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Arrays;
/*
* @Author: Wang Feng
* @Description:
* @Version: 1.0.0
* @Date: 15:04 2021/7/22
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class TestSM4 {
@Test
public void testSM4(){
try {
byte[] enc=BC_SM4.encrypt_ECB_Padding("1234567812345678".getBytes(StandardCharsets.UTF_8),
"wefree".getBytes(StandardCharsets.UTF_8));
System.out.println(Arrays.toString(enc));
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
| NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
}
}
}