当我在数据库上使用Symmetric Encryption然后将其备份然后将其还原到另一个SQL Server并使用相同的密钥时,我无法解密数据。
有解决方法吗?
使用SQL Server 2008
代码:
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PASSWORD'
GO
CREATE CERTIFICATE PasswordFieldCertificate WITH SUBJECT = 'Password Fields';
GO
CREATE SYMMETRIC KEY PasswordFieldSymmetricKey WITH ALGORITHM = TRIPLE_DES ENCRYPTION BY CERTIFICATE PasswordFieldCertificate;
GO
答案 0 :(得分:0)
将数据库备份还原到备份它的其他计算机:
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'Password'
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY
CLOSE MASTER KEY
注意:如果您不这样做,那么您将无法解密数据。