AES_ENCRYPT
Description
The aes_encrypt
function is used to perform AES (Advanced Encryption Standard) encryption on binary strings. This function supports multiple encryption modes, including ECB and GCM.
Parameter Description
expr
(binary): The binary string to be encrypted.key
(binary): The key used for encryption, the key length must be 16, 24, or 32 bytes.mode
(string): The encryption mode, optional values include 'ECB' and 'GCM'. The default value is 'ECB'.
Return Value
Returns the encrypted binary string.
Usage Example
Notes
- The key length must be 16, 24, or 32 bytes, otherwise encryption will fail.
- In GCM mode, a random initialization vector is generated each time encryption is performed, so the encryption results may vary.
- Using Base64 encoding makes it easy to transfer and store binary encrypted data in different environments.