Returns the value that results from encrypting a data string. The data type of the data string can be CHAR, VARCHAR, GRAPHIC, VARGRAPHIC, BINARY, VARBINARY, or BLOB. The result data type of the function is BLOB when the data string is a large object data type, VARBINARY when the data string is BINARY or VARBINARY, and VARCHAR FOR BIT DATA otherwise.
The password used for decryption is a CHAR or VARCHAR value representing the password that was used to encrypt the data string, if provided. If the password is not provided, the data will be encrypted and decrypted using the ENCRYPTION PASSWORD value assigned using the SET ENCRYPTION PASSWORD command.
Example:
Use the ENCRYPTION PASSWORD value to hold the encryption password:
SET ENCRYPTION PASSWORD='BEN123'; INSERT INTO EMP (SSN) VALUES ENCRYPT_RC2('289-46-8832');