Was this helpful?
Encryption Functions
Encryption functions encrypt data stored in tables. The encryption functions include AES_ENCRYPT and AES_DECRYPT. For more information, see the Security Guide.
AES_ENCRYPT
AES_ENCRYPT(column_name,'encryption_passphrase'[,KEY_SIZE=128|192|256])
Operand type: Any character type. The function accepts only VARBYTE, so compatible types are automatically converted to VARBYTE. If the value being encrypted is integer, float or another data type incompatible with VARBYTE, it is necessary to explicitly cast the data.
Result type: VARBYTE
Encrypts the values to be inserted or updated in a table. The data can be read only by using the AES_DECRYPT function, supplying the encryption passphrase. The key size, if not specified, defaults to 128.
Example:
INSERT INTO socsec2 SELECT
        fname, lname,
        AES_ENCRYPT(socsec,'user function encryption')
        FROM socsec1
AES_DECRYPT
AES_DECRYPT(column_name,'encryption_passphrase'[,KEY_SIZE=128|192|256])
Operand type: VARBYTE
Result type: VARBYTE
Decrypts data (allows encrypted data to be read in plain text) by supplying the encryption passphrase. The key size, if not specified, defaults to 128.
Example:
SELECT columnname, columnname,
        AES_DECRYPT(columnname,'encryption_passphrase') AS columnname
        FROM table2
Last modified date: 01/30/2023