Securing data by using DB2 encryption
Data encryption becomes very crucial in handling confidential data. Data can be encrypted during transit and at storage level. In this recipe, we will focus on encrypting the stored data. DB2 provides various functions that can be used to encrypt and decrypt the data. These functions can be embedded in any host language, just like a regular function or statement. Data is encrypted into BIT DATA
, so before we can use encryption, we should have the target table designed to support the encrypted data.
Getting ready
We will use DB2 encryption functions to encrypt and decrypt the data in a test table. The following statement creates a test table that we will use in our recipe:
CREATE TABLE TEST_ENCRYPTION
(ID INTEGER,
NAME VARCHAR(30),
CONFIDENTIAL_INFO VARCHAR(100) FOR BIT DATA);
Because the encrypted data is BIT DATA, we need to define our target column as FOR BIT DATA.
How to do it...
In this recipe, we will see how we can use encryption functions provided...