SM4 National Encryption is an online SM4 Chinese national standard symmetric encryption/decryption tool. SM4 is a block cipher algorithm published by Chinas State Cryptography Administration (GB/T 32907-2016), with both block size and key length fixed at 128 bits (16 bytes). This tool supports ECB / CBC / CFB / OFB / CTR five cipher modes, PKCS#7 / ISO 9797-1 / ANSI X.923 / ISO 10126 / Zero Padding / No Padding six padding schemes, and Base64 / Hex two output encodings. All operations are performed locally in your browser — no data is ever uploaded to any server.
Enter or click the random button to generate a key (SM4 uses a fixed 16-byte, 128-bit key)
Select a cipher mode (ECB / CBC / CFB / OFB / CTR). Non-ECB modes require an IV offset (16 bytes)
Choose a padding scheme and output encoding (Base64 / Hex), then paste or type text into the input area
Click "Encrypt" to encrypt or "Decrypt" to decrypt
The result will appear on the right — you can copy or download it, or use the swap button to exchange input and output
Strictly follows the Chinese national standard GB/T 32907-2016 "SM4 Block Cipher Algorithm", meeting national crypto compliance requirements
Free daily usage is provided for every user, so routine encryption needs can be met at zero cost; frequent or professional use can unlock more quota by subscribing to membership
All encryption and decryption run entirely in your browser; your key and data are never uploaded to any server, providing 100% privacy protection
Supports ECB / CBC / CFB / OFB / CTR — five mainstream cipher modes covering most business scenarios
Provides PKCS#7, ISO 9797-1, ANSI X.923, ISO 10126, Zero, No padding schemes plus Base64 / Hex output encodings
Built-in secure random key and IV generation lets you create length-compliant, high-strength keys in one click, simplifying setup
Different cipher modes determine how data blocks relate to each other, affecting security and applicable scenarios:
| Mode | Full Name | Requires IV | Description |
|---|---|---|---|
| ECB | Electronic Codebook | No | Each block is encrypted independently; identical plaintext produces identical ciphertext — not recommended for long texts |
| CBC | Cipher Block Chaining | Yes | Each block depends on the previous ciphertext block; high security, the most commonly used mode |
| CFB | Cipher Feedback | Yes | Converts block cipher to stream cipher; suitable for real-time encryption |
| OFB | Output Feedback | Yes | Converts block cipher to stream cipher; errors do not propagate |
| CTR | Counter Mode | Yes | Converts block cipher to stream cipher; supports parallel processing, good performance |
When the plaintext length is not a multiple of the block size (16 bytes), padding is needed:
SM4 (formerly SMS4) is a symmetric block cipher published by China's State Cryptography Administration, one of the core algorithms in China's national cryptographic standard system:
Compare SM4 with AES, DES, and other symmetric encryption algorithms:
| Dimension | SM4 | AES | DES |
|---|---|---|---|
| Block Size | 128 bits | 128 bits | 64 bits |
| Key Length | 128 bits | 128/192/256 bits | 56 bits |
| Encryption Rounds | 32 rounds | 10/12/14 rounds | 16 rounds |
| Security | High, national standard | High, international standard | Low, can be brute-forced |
| Standardization | Chinese national standard GB/T 32907 | International standard NIST FIPS 197 | Legacy standard, deprecated |
SM4 (formerly SMS4) is a symmetric block cipher algorithm published by China's State Cryptography Administration in 2006, confirmed as a national cryptographic industry standard in 2012, and became a national standard (GB/T 32907-2016) in 2016. SMS4 is the old name, SM4 is the official name after standardization — the two algorithms are identical, only the name was simplified from "SMS4" to "SM4".
Both are secure symmetric block ciphers: SM4 has a 128-bit block size, fixed 128-bit key, 32 rounds, and is a Chinese national standard; AES has a 128-bit block size, supports 128/192/256-bit keys, 10/12/14 rounds, and is an international standard. For information systems within China, especially in government, finance, and other critical sectors, SM4 should be prioritized to meet national cipher compliance requirements. For international scenarios, AES offers broader compatibility.
SM4 key length is fixed at 128 bits (16 bytes). English letters, digits, and symbols each occupy 1 byte; a Chinese character typically occupies 3 bytes. We recommend using a 16-character alphanumeric combination as the key, or clicking the random generation button next to the key input field to automatically generate a compliant key.
Yes, decryption must use exactly the same key, cipher mode, padding scheme, and output encoding as encryption — otherwise decryption will fail or produce garbled output. The IV offset must also be identical (except in ECB mode). It's recommended to save the encryption parameters together with the ciphertext.
CBC mode is generally recommended — it is the most commonly used mode with good security and broad compatibility. ECB mode is not recommended for sensitive data as identical plaintext produces identical ciphertext, risking pattern leakage. CFB, OFB, and CTR convert the block cipher to a stream cipher, suitable for real-time encryption scenarios.
Possible reasons: ① Incorrect key or mismatched length (must be 16 bytes); ② Cipher mode or padding scheme does not match what was used for encryption; ③ Wrong output encoding (if Base64 was used for encryption, select Base64 for decryption too); ④ The input is not valid SM4 encrypted data.
No. All encryption/decryption operations run entirely in your browser. Your keys and data never leave your device.
The tool supports ECB / CBC / CFB / OFB / CTR cipher modes and PKCS#7 / ISO 9797-1 / ANSI X.923 / ISO 10126 / Zero Padding / No Padding padding schemes, covering most integration scenarios. ECB mode needs no IV, while other modes require a 16-byte IV offset.
This tool provides free daily usage, so routine lightweight needs can be met at zero cost. No registration or login is required — just open the page and use it. When you need higher processing volumes or more frequent use, subscribing to membership unlocks more benefits to handle various scenarios with ease.
Absolutely. The tool processes text using UTF-8 encoding, so Chinese, Japanese, Korean, and any other Unicode characters can be encrypted and decrypted normally. Text is converted to UTF-8 byte sequences when encrypting and restored when decrypting.
Their performance is very close; both are efficient symmetric block ciphers. SM4 uses 32 rounds, while AES uses 10/12/14 rounds (depending on key length). For ordinary text, both SM4 and AES complete encryption/decryption instantly in the browser — users can barely notice a difference.
No Padding mode requires the plaintext length to be a multiple of 16 bytes. If decryption errors or produces garbled output, check: ① whether the plaintext length used during encryption was a multiple of the block size; ② whether the ciphertext length is a multiple of 16 bytes; ③ whether the key, mode, and IV exactly match those used during encryption.
Content last updated:2026-07-15
Online DES/2DES/3DES encryption and decryption tool, supporting all encryption modes and padding methods. Fully processed locally in the browser for security and efficiency.
Online AES encryption and decryption tool, supporting AES-128/192/256, covering all encryption modes and padding methods, secure, efficient, and easy to operate.
Online 3DES encryption/decryption tool, supporting all encryption modes and padding methods, fully processed locally in the browser to ensure data security.
Online RC4 stream cipher encryption/decryption tool, supports multiple key lengths, one-click encryption and decryption, all operations are completed locally in the browser to ensure data security.
Online Rabbit stream cipher encryption/decryption tool, using a high-speed symmetric encryption algorithm, supporting multiple key lengths. All operations are performed locally in the browser to ensure data security.
Online RC2 encryption and decryption tool, supporting ECB/CBC modes, variable key length and effective key bits, all processed locally in the browser to ensure data security.
Online IDEA International Data Encryption Algorithm Tool, supporting multiple encryption modes including ECB/CBC/CFB/OFB/CTR. All operations are performed locally in the browser to ensure data security.
Online Blowfish encryption/decryption tool supporting 128/192/256/448-bit variable keys, ECB/CBC/CFB/OFB modes, and multiple padding methods. All operations are performed locally in the browser to ensure data security.
CAST-128 (CAST5) online encryption and decryption tool, supporting multiple encryption modes such as ECB/CBC/CFB/OFB, flexible padding methods, and output encoding. All operations are performed locally in the browser, ensuring security and efficiency.
Online RSA asymmetric encryption and decryption tool, supporting key pair generation, public key encryption and private key decryption, private key signing and public key verification. All operations are performed locally in the browser to ensure data security.
Online MD5 hash encryption tool, supporting 16-bit/32-bit output, case switching, and file MD5 verification. All operations are completed locally in the browser, ensuring security and efficiency.
MD2 Encryption Tool: Generate 32-bit MD2 hash values online, supporting uppercase/lowercase output and file verification.
Online SHA-1 hash calculation tool for efficient text encryption and file integrity verification.
Online SHA-256 hash calculation tool for quick text encryption and file integrity verification.
Online SHA-384 hash calculation tool for fast text encryption and file integrity verification.
Online SHA-512 hash calculation tool, supporting text encryption and file integrity verification, quickly generating secure hash values.
Online SM3 National Hash Encryption Tool, supports text hash calculation and file verification, outputs a 256-bit hash value, compliant with GM/T 0004-2012 national standard.
Online Base64 encode/decode tool, supporting text Base64 encoding and decoding, all done locally in the browser, safe and efficient.
Online URL encoding and decoding tool, supports intelligent encoding and decoding of URL parameters, automatically identifies URL structure, processes only the parameter part, completes entirely in the browser locally, safe and efficient.
Online UTF-8 encoding/decoding tool, supporting conversion between text and UTF-8 hexadecimal bytes. All processing is done locally in the browser, ensuring data security.