Saturday, October 27, 2007

Applying Encryption on a column

1. Apply DB2 encryption on a column:

Step 1:
CREATE TABLE QUALIFIER.TEST_ENCRYPT (ACCT_NBR VARCHAR(32) FOR BIT DATA WITH DEFAULT NULL) CCSID EBCDIC
IN DBNAME.TSNAME AUDIT NONE;
Step 2:
INSERT INTO QUALIFIER.TEST_ENCRYPT
VALUES ENCRYPT_TDES ('12345678','12345678984&&^psw');
Step 3:
UPDATE QUALIFIER.TEST_ENCRYPT
SET ACCT_NBR= ENCRYPT_TDES ('12345678','12345678984&&^psw');
Step 4: (To access the data)
SET ENCRYPTION PASSWORD = 'psw';
select decrypt_char(ACCT_NBR,'12345678984&&^psw') from QUALIFIER.TEST_ENCRYPT ;
--SELECT * FROM QUALIFIER.TEST_ENCRYPT
--WHEN YOU SCREW UP AND DON'T REMEMBER YOUR PASSWORD
DELETE FROM QUALIFIER.TEST_ENCRYPT ;

No comments: