SM2 Public Key Cryptography

SM2 Chinese elliptic curve public key encryption algorithm, supporting encryption/decryption and digital signatures.

Key Generation

Encrypt/Decrypt

Sign/Verify

Instructions

About SM2

SM2 is an elliptic curve public key cryptography algorithm released by the State Cryptography Administration of China, based on elliptic curves over a 256-bit prime field, with security comparable to 2048-bit RSA. This tool uses the miller-sm2 library to implement SM2 encryption/decryption and digital signature functions.

Feature Description

Key Generation: randomly generate SM2 public/private key pair (HEX format); Encrypt/Decrypt: encrypt with public key, decrypt with private key, supports C1C3C2 (recommended) and C1C2C3 (legacy) ciphertext order; Sign/Verify: sign with private key, verify with public key, ensuring data integrity and non-repudiation.

Steps

1. Click 'Generate Key Pair' to get SM2 public/private keys; 2. Encrypt: Enter plaintext and recipient public key, click 'Encrypt'; 3. Decrypt: Enter ciphertext and recipient private key, click 'Decrypt'; 4. Sign: Enter text and sender private key, click 'Sign'; 5. Verify: Enter text, signature and sender public key, click 'Verify'.

Notes

SM2 uses a 256-bit elliptic curve, the public key is 64 bytes (32+32), the private key is 32 bytes; encryption result is longer than plaintext (includes verification info); all keys and ciphertext use HEX encoding.