Encrypting non-character values
Db2 supports encryption for numeric and datetime data types indirectly through casting. If non-character data is cast as VARCHAR or CHAR, the data can be encrypted.
Example
- Create a table to store the encrypted values and set the column-level
encryption password by using the following statements:
CREATE TABLE ETEMP (C1 VARCHAR(124) FOR BIT DATA); SET ENCRYPTION PASSWORD :hv_pass; - Cast, encrypt, and insert the timestamp data by using the following
statement:
INSERT INTO ETEMP VALUES ENCRYPT(CHAR(CURRENT TIMESTAMP)); - Recast, decrypt, and select the timestamp data by using the following
statement:
SELECT TIMESTAMP(DECRYPT_CHAR(C1)) FROM ETEMP;