Tutorial by Examples

CREATE CERTIFICATE My_New_Cert FROM FILE = 'D:\Temp\CertTest\certificateDER.cer' GO Create the certificate SELECT EncryptByCert(Cert_ID('My_New_Cert'), 'This text will get encrypted') encryption_test Usually, you would encrypt with a symmetric key, that key would get encrypted by the asym...
USE TDE CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE My_New_Cert GO ALTER DATABASE TDE SET ENCRYPTION ON GO This uses 'Transparent Data Encryption' (TDE)
-- Create the key and protect it with the cert CREATE SYMMETRIC KEY My_Sym_Key WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE My_New_Cert; GO -- open the key OPEN SYMMETRIC KEY My_Sym_Key DECRYPTION BY CERTIFICATE My_New_Cert; -- Encrypt SELECT EncryptByKey(Key_GUID('SSN_Key_01'),...
SELECT EncryptByPassphrase('MyPassPhrase', 'This text will get encrypted') This will also encrypt but then by passphrase instead of asymmetric(certificate) key or by an explicit symmetric key.

Page 1 of 1