Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to encrypt on one SQL Server and decrypt on another?
    primarykey
    data
    text
    <p>We would like to use SQL Server Encryption to encrypt a couple of columns within our databases. We also need to transfer data between our production and test environment. It seems like the best solution would be to use the same master key, certificate, and symmetric key on the production and test servers so that I could encrypt or decrypt the columns in either production or test environments with the same results.</p> <p>So far I have tried using the same create script in both environments which did not work. It encrypted on one server but did not decrypt on the other after data was transferred to the other server:</p> <pre><code>use &lt;database name&gt; CREATE MASTER KEY ENCRYPTION BY PASSWORD = &lt;password1&gt; use &lt;database name&gt; CREATE CERTIFICATE &lt;certificate name&gt; WITH SUBJECT = &lt;certificate subject&gt; use &lt;database name&gt; CREATE SYMMETRIC KEY &lt;key name&gt; WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE &lt;certificate name&gt; </code></pre> <p>And I have tried creating the master key, certificate, and symmetric key on one server and then restoring it on the other which doesn’t seem to <em>create the key</em> and therefore doesn’t work either.</p> <pre><code>use &lt;database name&gt; OPEN MASTER KEY DECRYPTION BY PASSWORD = &lt;password1&gt; BACKUP MASTER KEY TO FILE = 'c:\masterkey.txt' ENCRYPTION BY PASSWORD = &lt;password2&gt; use &lt;database name&gt; BACKUP CERTIFICATE &lt;certificate name&gt; TO FILE = 'c:\Cert.txt' WITH PRIVATE KEY ( FILE = 'c:\Key.txt' , ENCRYPTION BY PASSWORD = &lt;password3&gt; ) use &lt;database name&gt; RESTORE MASTER KEY FROM FILE = 'c:\masterkey.txt' DECRYPTION BY PASSWORD = &lt;password2&gt; ENCRYPTION BY PASSWORD = &lt;password1&gt; use &lt;database name&gt; OPEN MASTER KEY DECRYPTION BY PASSWORD = &lt;password1&gt; CREATE CERTIFICATE &lt;certificate name&gt; FROM FILE = 'c:\Cert.txt' WITH PRIVATE KEY (FILE = 'c:\Key.txt', DECRYPTION BY PASSWORD = &lt;password3&gt;) </code></pre> <p>How can I encrypt on one SQL Server and decrypt on another?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload