Merge branch 'master' of gitee.com:willfree/min-dev-java

This commit is contained in:
free will committed 2021-04-01 21:13:15 +08:00
commit 39999e0534
2 files changed
+32 -1

No files matched your search

@@ -19,7 +19,7 @@ import java.nio.charset.StandardCharsets;
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class HashAlgo {
// TODO: 单元测试 基本上只需要对sm3做单元测试
///////////////
///// SM3 /////
///////////////
@@ -0,0 +1,31 @@
package minsecurity.crypto;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import org.junit.Test;
import static org.junit.Assert.*;
/*
* @Author: feng Zhao
* @Description:
* @Version: 1.0.0
* @Date: 14:56 2021/3/29
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class TestSM3 {
@Test
public void testSm3() {
HashAlgo hashAlgo = new HashAlgo();
String srcString = "123456";
byte[] srcData = srcString.getBytes();
byte[] resultHash = hashAlgo.sm3(srcData);
String sm3HexString = ByteUtils.toHexString(resultHash);
byte[] sm3Hash = ByteUtils.fromHexString(sm3HexString);
byte[] newHash = hashAlgo.sm3(srcString);
assertArrayEquals(sm3Hash,newHash);
}
}