Friday, July 5, 2013

DB2 TDES Encryption on Mainframe

TDES Encryption Algorithm can be used in DB2 tables as well. Suppose confidential numbers needs to be stored .We can ENCRYPT the value and store it.
Lets create the DB2 table like below


CREATE TABLE U202.CUST_DATA                                      
     (U_STR                CHAR(3) FOR SBCS DATA NOT NULL,         
      U_REG                CHAR(6) FOR SBCS DATA NOT NULL,         
      U_SKU                INTEGER NOT NULL,                       
      U_GIFT               CHAR(3) FOR SBCS DATA NOT NULL,         
      U_CREDIT_CARD        VARCHAR(40) FOR BIT DATA NOT NULL)

Now lets insert values into the table:

SET ENCRYPTION PASSWORD ='PWD1APRIL@' 
INSERT INTO U202.CUST_DATA                         
 VALUES('001', '123456', 1234, 'LCD', ENCRYPT_TDES ('9876543210123456'))

Now To Decrypt 

SET ENCRYPTION PASSWORD ='PWD1APRIL@';                       
SELECT DECRYPT_CHAR ("U_CREDIT_CARD") FROM U202.CUST_DATA 





No comments:

Post a Comment