Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to encrypt one of my sensitive columns in a SQL Server table. I tried AES256 encryption with this script, and it works perfect. But I don't want to create Certificates, or Symmetric Keys on my SQL Server as it may be a security problem later. How can I encrypt the data with a single password or key in my query ? Another problem with this method is, I can use only a single master password for my encryption.

SQL
CREATE MASTER KEY ENCRYPTION
  BY PASSWORD = '$Passw0rd'
  GO

  CREATE CERTIFICATE AESEncryptTestCert
  WITH SUBJECT = 'AESEncrypt'
  GO

  CREATE SYMMETRIC KEY AESEncrypt
  WITH ALGORITHM = AES_256 ENCRYPTION
  BY CERTIFICATE AESEncryptTestCert;


 OPEN SYMMETRIC KEY AESEncrypt DECRYPTION
 BY CERTIFICATE AESEncryptTestCert
 SELECT ENCRYPTBYKEY(KEY_GUID('AESEncrypt'),'The text to be encrypted');
Posted
Comments
virang_21 9-Feb-15 0:12am    
There is an option of transparent data encryption at SQL Server database level... http://sqlmag.com/database-security/sql-server-encryption-options
Yesudass Moses 9-Feb-15 0:15am    
But, I need column level encryption only. for just a single column (amount)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900