Last active
August 29, 2015 14:18
-
-
Save JustinMcNamara74/ec1fd320f224c89fc111 to your computer and use it in GitHub Desktop.
#MSSQL Creates all items necessary for SQL Server Encryption/Decryption
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
/** | |
A few notes: | |
- Remember the DB Master Key!! | |
- When creating certificates/keys be descriptive, as there may be many on your instance of SQL Server | |
**/ | |
IF (select Count(*) from sys.symmetric_keys where name like '%DatabaseMasterKey%') = 0 | |
BEGIN | |
CREATE master key Encryption by password = 'SomePassword'; | |
END | |
IF (select Count(*) from sys.certificates where name = 'CertificateName') = 0 | |
BEGIN | |
CREATE CERTIFICATE CertificateName with subject = 'Description Of Encryption'; | |
END | |
IF (select count(*) from sys.symmetric_keys where name = 'EncrytionKeyName') = 0 | |
BEGIN | |
-- Algorithm Options: DES,Triple DES,TRIPLE_DES_3KEY,RC2,RC4,128-bit RC4,DESX,128-bit AES,192-bit AES,256-bit AES. | |
CREATE symmetric key EncryptionKeyName with algorithm=TRIPLE_DES Encryption by certificate CertificateName; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment