SM3 digests and SM2 signing/encryption
A national-crypto toolkit: SM3 digests (GM/T 0004-2012), HMAC-SM3 (RFC 2104 construction), and SM2 signing/verification plus public-key encryption (GB/T 32918). SM3 output matches node:crypto sm3 byte for byte; SM2 needs your own hex or PEM keys. SM4 symmetric encryption lives on the dedicated SM4 page.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
Everything is computed locally; inputs and keys are never uploaded.
Enter content to see the result
Input bytes: 0 · Output bytes: 0 · Block bytes: 0 · Operation index: 0
What this tool does
- Compute an SM3 digest and cross-check it against node:crypto.
- Compute HMAC-SM3 with a fixed key for request signing.
- Sign, verify, encrypt or decrypt with your own SM2 keys.
Example
Input
abc
Output
# SM3 摘要(GM/T 0004-2012) # inputBytes = 3 outputBytes = 32 blocks = 1 # digest = 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 # digest 前 32 字节 = 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0
SM3("abc") = 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 (GM/T 0004-2012 Appendix A, matches node:crypto).
Frequently asked questions
How does SM3 relate to SHA-256?
Both output 256 bits, but the constructions are completely different (SM3 is the Chinese standard GM/T 0004-2012 with its own compression function and message expansion), so the same input always yields different digests.
How is HMAC-SM3 different from SM3?
HMAC wraps the digest in a keyed construction (RFC 2104: K ⊕ opad || H(K ⊕ ipad || M)) with a 64-byte block; without the key the value cannot be reproduced.
What key formats does SM2 accept?
Signature r/s values and the public/private keys accept hex or PEM. A bad format reports invalid-pem / invalid-key instead of silently producing a wrong result.
Does it support SM4?
No — SM4 is a symmetric block cipher and lives on the dedicated SM4 page. This page implements SM3 and SM2 only.
Keywords:SM3HMAC-SM3SM2GM/T 0004