Last active
September 29, 2020 09:18
-
-
Save chenbojian/ed4c2885a98f56d8eced8b06aca2a169 to your computer and use it in GitHub Desktop.
TDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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