mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
sm3小Test
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user