Class Sm3Util
java.lang.Object
com.sure.tool.crypto.Sm3Util
国密 SM3 杂凑算法工具类(纯 JDK 实现,零第三方依赖)。
SM3 输出 256 位(32 字节)摘要,是国家密码管理局发布的商用密码杂凑算法, 用于完整性校验、数字签名等场景。实现遵循 GB/T 32905-2016。
用法示例:
String hex = Sm3Util.sm3Hex("abc"); // 66c7f0f4...
String b64 = Sm3Util.sm3Base64("abc");
byte[] digest = Sm3Util.sm3("abc".getBytes(StandardCharsets.UTF_8));
- Since:
- 1.0.1
- Author:
- suretool
-
Method Details
-
sm3
public static byte[] sm3(byte[] data) 计算 SM3 摘要。- Parameters:
data- 输入字节- Returns:
- 32 字节摘要
-
sm3Hex
计算 SM3 摘要(十六进制小写)。- Parameters:
data- 输入字节- Returns:
- 64 位十六进制摘要
-
sm3Hex
-
sm3Base64
-
sm3Base64
计算字节数组的 SM3 摘要(Base64)。- Parameters:
data- 输入字节- Returns:
- Base64 摘要
-