SM2 Chinese Cryptographic Algorithm
Elliptic curve cryptography per GM/T 0003-2012. Generate key pairs, encrypt/decrypt, sign/verify — all in-browser.
1. SM2 Key Pair
2. Encryption / Decryption
3. Sign / Verify
SM2 is an elliptic curve cryptographic algorithm standardized by the Chinese State Cryptography Administration (GM/T 0003-2012). It uses the SM2 curve (256-bit prime field) and is paired with SM3 hashing. This tool uses the sm-crypto JavaScript library.
SM2 encryption uses C1C2C3 format (hex output). Signatures use r||s format (raw concatenation). The public key is in compressed format (02/03 prefix + 64 hex chars).
How to Use
Encrypt: Generate a key pair. Enter plaintext, click "Encrypt with Public Key". The output is a hexadecimal C1C2C3 ciphertext string.
Decrypt: Paste a hex C1C2C3 ciphertext, ensure the private key matches, click "Decrypt with Private Key".
Sign: Enter a message, click "Sign with Private Key". The message is first hashed with SM3, then signed. Output is hex r||s (64 bytes = 128 hex chars).
Verify: Enter the original message and the hex signature, click "Verify with Public Key".
When to Use SM2 vs RSA vs ECDSA
- SM2 — Required for Chinese government, finance, and compliance applications
- RSA — Widest compatibility, mature ecosystem, supported everywhere
- ECDSA (P-256) — Better performance than RSA, widely used in TLS 1.3 and WebAuthn
Example Use Cases
- Chinese banking — SM2 is required for Chinese financial IC card applications
- Government systems — Mandated for Chinese government information systems
- IoT security — Lightweight compared to RSA, suitable for embedded devices
- Interoperability testing — Verify SM2 implementations across Java (BouncyCastle), C (GMSSL), and JavaScript