SM4EncryptECBPKCS7
Cryptography
Description
Encrypts a payload of any length with SM4 in ECB mode, applying PKCS#7 padding before the cipher runs
Syntax
Delphi
Function SM4EncryptECBPKCS7(Const Key, Plaintext: AnsiString): AnsiString;Parameters
| Key | Exactly 16 bytes |
|---|---|
| Plaintext | Any length; padded to the next 16-byte boundary before encryption |
Return values
| The padded ciphertext, or an empty string on any invalid input |
Remarks
Part of the pure-Pascal SM4 block cipher (GB/T 32907-2016)
The PKCS#7 layer appends 1..16 pad bytes so the payload becomes a multiple of the 16-byte block size; a full block is added when the input is already aligned
ECB mode repeats plaintext patterns across identical blocks; prefer SM4EncryptCBCPKCS7 whenever an IV can be transmitted
See also
SM4DecryptECBPKCS7, SM4EncryptECB, SM4EncryptCBCPKCS7, SM4PadPKCS7