sm3小Test

This commit is contained in:
zhaofeng233 committed 2021-04-01 20:55:27 +08:00
1 parent c45667cc8d
commit d61affa761
1 file changed
+31
@@ -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);
}
}