SM2 Encryption/Decryption Online

Online SM2 public key cryptography tool. Chinese national standard encryption algorithm for digital signatures and key exchange.

Key Pair Management

Format:

Encryption & Decryption

Plain Text Format:
Cipher Text Format:
Cipher Structure:

Digital Signature

Message to Sign
Signature Result

About SM2

What is SM2?

SM2 is a public key cryptographic algorithm based on elliptic curves. It is part of Chinese commercial cryptography standard.

Key Features

SM2 provides similar security level as RSA-2048 with shorter key lengths, making it more efficient.

Applications

Widely used in Chinese financial systems, government systems, and digital certificates.

Ciphertext Format & 04 Prefix

According to the GB/T 32918.4 standard, SM2 encrypted output uses the uncompressed elliptic curve point format. The first byte must be 0x04, indicating that the subsequent data contains the full X and Y coordinates. This tool allows you to select whether to include this standard 0x04 prefix in the encrypted result. The ciphertext structure consists of C1 (public key point), C2 (encrypted data), and C3 (hash value).

Cipher Structure: C1C3C2 vs C1C2C3

SM2 encryption defines two common ciphertext concatenations. The original Chinese state standard used the `C1C2C3` structure by default; however, the newer GB/T 32918.4-2016 standard mandates the `C1C3C2` structure. This tool uses `C1C3C2` as the default but provides a compatibility option for `C1C2C3`.

Key Format: PEM vs Raw Hex

Keys are typically stored and transmitted in the standard `PEM` format (e.g., Base64 encoded strings headered with `-----BEGIN PUBLIC KEY-----`). `Raw Hex` represents the raw hexadecimal data used by cryptographic algorithms. This tool natively supports conversion and parsing between these two formats for integration flexibility.