Encrypting field data in a pre-existing table
Posted: Fri 31 Aug 2012 14:24
I am currently demoing the latest version of IBDAC components which includes the TIBCEncryptor component. I have followed the example in the new help file, and am able to encrypt any new data entered into the fields, but I would like to know how to encrypt all of the pre-existing data.
For example...
Say I started with the following:
CREATE TABLE CLIENTS (
CLIENT_ID INTEGER NOT NULL PRIMARY KEY,
CLIENT_NAME VARCHAR(200),
PHONE_1 VARCHAR(12),
PHONE_2 VARCHAR(12)
)
There are many records with phone numbers already existing.
Now, before setting up the new encryption, I am running the following...
ALTER TABLE CLIENTS ALTER COLUMN PHONE_1 TYPE VARCHAR(200) CHARACTER SET OCTETS;
ALTER TABLE CLIENTS ALTER COLUMN PHONE_2 TYPE VARCHAR(200) CHARACTER SET OCTETS;
Next, I point the query to the IBCEncryptor and set the proper options to encrypt PHONE_1 & PHONE_2.
If I change or alter one of the phone #'s and post the record, the data becomes encrypted as expected, but the other field that was not changed remains unencrypted.
Is there a way for me to call a procedure or update all existing data in the fields which I want to be encrypted? I tried using an sql query to set the data equal to itself, ex. SET PHONE_1 = PHONE_1, but that did not encrypt the data. These are large tables and I would like to make sure all of the existing data is encrypted before new rows are added.
Any suggestions/examples would be greatly appreciated.
[Edit] Also, when using the tag & hash method, is there a way to tell if the field data is encrypted? A function or something? Thanks.
For example...
Say I started with the following:
CREATE TABLE CLIENTS (
CLIENT_ID INTEGER NOT NULL PRIMARY KEY,
CLIENT_NAME VARCHAR(200),
PHONE_1 VARCHAR(12),
PHONE_2 VARCHAR(12)
)
There are many records with phone numbers already existing.
Now, before setting up the new encryption, I am running the following...
ALTER TABLE CLIENTS ALTER COLUMN PHONE_1 TYPE VARCHAR(200) CHARACTER SET OCTETS;
ALTER TABLE CLIENTS ALTER COLUMN PHONE_2 TYPE VARCHAR(200) CHARACTER SET OCTETS;
Next, I point the query to the IBCEncryptor and set the proper options to encrypt PHONE_1 & PHONE_2.
If I change or alter one of the phone #'s and post the record, the data becomes encrypted as expected, but the other field that was not changed remains unencrypted.
Is there a way for me to call a procedure or update all existing data in the fields which I want to be encrypted? I tried using an sql query to set the data equal to itself, ex. SET PHONE_1 = PHONE_1, but that did not encrypt the data. These are large tables and I would like to make sure all of the existing data is encrypted before new rows are added.
Any suggestions/examples would be greatly appreciated.
[Edit] Also, when using the tag & hash method, is there a way to tell if the field data is encrypted? A function or something? Thanks.