Skip to content

Instantly share code, notes, and snippets.

@chenbojian
Last active September 29, 2020 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chenbojian/ed4c2885a98f56d8eced8b06aca2a169 to your computer and use it in GitHub Desktop.
Save chenbojian/ed4c2885a98f56d8eced8b06aca2a169 to your computer and use it in GitHub Desktop.
TDE
USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<UseStrongPasswordHere>';
go
CREATE CERTIFICATE TDECert WITH SUBJECT = 'TDE Certificate';
go
----------------
USE [DB-local];
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_128
ENCRYPTION BY SERVER CERTIFICATE TDECert;
GO
ALTER DATABASE [DB-local]
SET ENCRYPTION ON;
GO
------------------
USE master;
GO
BACKUP CERTIFICATE TDE_CERT_For_MyData
TO FILE = 'C:\temp\TDE_Cert_For_MyData.cer'
WITH PRIVATE KEY (file='C:\temp\TDE_CertKey.pvk',
ENCRYPTION BY PASSWORD='Provide Strong Password for Backup Here');
-------------------
USE master;
GO
CREATE CERTIFICATE TDECert
FROM FILE = 'C:\temp\TDE_Cert_For_MyData.cer'
WITH PRIVATE KEY (
FILE = N'C:\temp\TDE_CertKey.pvk',
DECRYPTION BY PASSWORD = 'Provide Strong Password for Backup Here'
);
GO
---------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment