Skip to content
UniKit

SM2 cryptography

SM2 public-key encryption and private-key decryption, signing and verification, plus key-pair generation, ZA computation and self-verification. Accepts bare hex, the one-line sm2-priv:/sm2-pub: forms and PKCS#8 / SPKI PEM — all computed locally with pure logic, keys never uploaded.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Content

Result

Computed locally; keys are never uploaded.

Enter content to see the result

Operation index: 0 · ZA bytes: 0 · Input bytes: 0 · Output bytes: 0

What this tool does

  • Encrypt or decrypt text with an SM2 key pair, or sign and verify text with SM2
  • Generate a demo key pair (the default private key is the public GM/T example 3945208F…C5B8) and inspect ZA, the public key and the PEM output
  • Check r/s values, ZA = SM3(ENTL‖ID‖a‖b‖Gx‖Gy‖Px‖Py) and the self-verification result against test vectors

Example

Input

hello

Output

# SM2 签名(e = SM3(ZA || M),userId=1234567812345678)
# r = 46be953c6dc0eb93a833bf363e98b96a7c0248ac2fdc42f0654bd6e250459295
# s = 87792787fd339645fb2013a29674e6eafecf1f0b0aad6f23d281a157e887eade
# signatureHex = 46be953c6dc0eb93a833bf363e98b96a7c0248ac2fdc42f0654bd6e25045929587792787fd339645fb2013a29674e6eafecf1f0b0aad6f23d281a157e887eade
# 自校验(同一实现反向验签)= VALID
# k = 未指定(用确定性回退)

Real output for the sign mode (operation "SM2 sign") with the pure function defaults (private key = the public GM/T example 3945208F…C5B8, no nonce k) and the input hello: ZA uses the default userId 1234567812345678, e = SM3(ZA‖M), r/s are 32 bytes each, and the deterministic fallback makes the signature reproducible. The page overrides two of those defaults — demo key d=1 and k=2 — so its default signature differs from this example.

Frequently asked questions

Are keys uploaded?

No. The SM2 curve parameters, SM3 hashing, encryption/decryption and signature verification all run in pure functions on this page with no network requests; generated keys only appear in the page.

Why is the signature always the same?

SM2 signing needs a random nonce k. For reproducibility this tool uses a deterministic fallback when k is left blank (fill k to control it), so the same input always produces the same r/s. Production signing must use a true random k, so do not treat this as a signing service.

Which key formats are accepted?

Private keys: bare hex, the one-line form sm2-priv:<hex>, or a PKCS#8 PRIVATE KEY PEM. Public keys: 04‖x‖y, x,y, the one-line form sm2-pub:…, or an SPKI PUBLIC KEY PEM. Bad input reports invalid-key.

Can I use the output for real encryption?

No. This is a browser-only tool for demonstration and test-vector checking; it has no secure randomness source, key protection or side-channel hardening and cannot replace OpenSSL / GmSSL.

Keywords:SM3ZAsm2 keygenPKCS#8

Related tools