Encrypt and decrypt data for security purposes.
mode
(String
): Encryption mode. Supported modes:
plaintext
(String
): Text to be encrypted.key
(String
): Encryption key. Length depends on mode:
iv
(String
, optional): Initialization vector. Required for -gcm modes, optional for others. Always 16 bytes (excess bytes are ignored).aad
(String
, optional): Additional authenticated data. Only used in -gcm modes.String
).mode
(String
): Encryption mode.plaintext
(String
): Text to be encrypted.key
(String
): Encryption key. If longer than required by the mode, MySQL-specific key folding is performed.iv
(String
): Initialization vector. Optional. Only the first 16 bytes are used.String
)encrypt
for equal inputs.aes_encrypt_mysql
follows MySQL’s behavior: ‘folding’ the key and ignoring excess bits of iv.mode
(String
): Decryption mode. Supported modes:
ciphertext
(String
): Encrypted text to be decrypted.key
(String
): Decryption key.iv
(String
, optional): Initialization vector. Required for -gcm modes, optional for others.aad
(String
, optional): Additional authenticated data. Only used in -gcm modes.String
]mode
(String
): Decryption mode.ciphertext
(String
): Encrypted text that needs to be decrypted.key
(String
): Decryption key.iv
(String
): Initialization vector. Required for -gcm modes, optional for others.aad
(String
): Additional authenticated data. Works only in -gcm modes.String
)tryDecrypt
:
tryDecrypt
is useful when you want to handle decryption failures gracefully without throwing exceptions, especially when dealing with data encrypted with different keys.aes_encrypt_mysql
function.
Syntax:
mode
(String
): Decryption mode.ciphertext
(String
): Encrypted text to be decrypted.key
(String
): Decryption key.iv
(String
): Initialization vector. Optional.String
)
decrypt
on equal inputs.
When key or iv are longer than required, it follows MySQL’s behavior: ‘folds’ the key and ignores excess bits of IV.aes_encrypt_mysql
. The decrypted result reveals the secret recipe name.