Pages

Friday 15 July 2011

MS SQL Server 2008 DB Encryption

Symmetric Key:

CREATE SYMMETRIC KEY SalesInventory_Key1
WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE FZ-DB02;

Encryption:

UPDATE FZ_SALES.Products
SET Inventory_Encrypted = EncryptByKey(Key_GUID('SalesInventory_Key1'),
Inventory, 1, HashBytes ('SHA1', CONVERT( varbinary. Inventory))); GO

The following should be done to before running the above script:

You must open the symmetric key with which to decrypt the data before running the update statement on the table. The command syntax is:

OPEN SYMMETRIC KEY SalesInventory_Key1 DECRYPTION BY
CERTIFICATE FZ- DB02

The symmetric must be opened with the FZ-DB02 certificate before you encrypt the value in the column Salary and save the results in the column Inventory_Encrypted

No comments:

Post a Comment