About SM4 Encryption Tool
SM4 is a 128-bit block cipher, currently established as a national standard (GB/T 32907-2016) of China. Multiple block cipher modes are supported. When using CBC or ECB mode, the PKCS#7 padding scheme is used.
Input: text. Output: text.
Format reference: SM4 Encrypt background and specification
Example
Use “Try example” to load this public sample and its settings, then run it.
Settings used in this example
| Parameter | Example value | Input and choices |
|---|---|---|
| Key | {"string":"01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10","option":"Hex"} | Key/text encoding: Hex, UTF8, Latin1, Base64 |
| IV | {"string":"","option":"Hex"} | Key/text encoding: Hex, UTF8, Latin1, Base64 |
| Mode | ECB/NoPadding | CBC, CFB, OFB, CTR, ECB, CBC/NoPadding, ECB/NoPadding |
| Input | Hex | Raw, Hex |
| Output | Hex | Hex, Raw |
Sample keys and passwords are public. Never use them to protect real data.
Input
aa aa aa aa bb bb bb bb cc cc cc cc dd dd dd dd ee ee ee ee ff ff ff ff aa aa aa aa bb bb bb bb
Result
5e c8 14 3d e5 09 cf f7 b5 17 9f 8f 47 4b 86 19 2f 1d 30 5a 7f b1 7d f9 85 f8 1c 84 82 19 23 04
Parameters
| Parameter | Default value | Input and choices |
|---|---|---|
| Key | {"option":"Hex","string":""} | Key/text encoding: Hex, UTF8, Latin1, Base64 |
| IV | {"option":"Hex","string":""} | Key/text encoding: Hex, UTF8, Latin1, Base64 |
| Mode | CBC | CBC, CFB, OFB, CTR, ECB, CBC/NoPadding, ECB/NoPadding |
| Input | Raw | Raw, Hex |
| Output | Hex | Hex, Raw |
Before interpreting the result
Use the exact key encoding, mode, padding and IV expected by the source system. Historical ciphers are useful for learning and analysis. Encoding alone provides no confidentiality.
How to use this page
- Paste your input or open a local file.
- Adjust tool options if needed, then choose Run tool.
- Copy the result or download the original output bytes.
Inputs and results are not added to the public catalogue or saved in the URL. Processing happens in your browser; HTTP Request and DNS over HTTPS send the requests you explicitly run. Files up to 128 MiB can be opened; decompression and image tools may have smaller processing limits. Large results have a shortened preview. Text and HTML downloads use UTF-8; binary downloads preserve output bytes. Pasted text follows browser newline handling; open a file when exact input bytes matter.