【发布时间】:2010-09-16 02:38:17
【问题描述】:
我想加密 SQL Server 2005 中的现有列,使用 UPDATE 语句,将旧内容移动到新的加密列中。
所以我有 2 个选择:对称和非对称。
我遇到的问题是,使用对称密钥,我必须将密码嵌入到 SP 中才能读取如下列:
-- Create key (at some earlier point)
create symmetric key sk_user_profile with algorithm = aes_192 encryption by password = 'P@ssword!!';
-- Now encrypt the contents
-- open the key so that we can use it
open symmetric key sk_user_profile decryption by password = 'P@ssword!!';
UPDATE users
SET password_enc = encryptbykey(key_guid('sk_user_profile'), password_plain, 1, user_id)
close symmetric key sk_user_profile
现在如果我想选择数据,我仍然需要重新打开密钥
open symmetric key sk_user_profile decryption by password = 'P@ssword!!';
这不是重点,因为我在存储过程中嵌入了纯文本密码。
一些问题
- 有什么办法可以解决这个问题 - 即使用此密码创建一个证书,然后改为引用该证书?
- 是否必须购买此证书(如 SSL),还是我可以自己创建?
- 此方法是否可跨故障转移集群数据库进行扩展,即加密不基于机器,仅基于提供的密码。因此故障转移仍然可以读取密码
感谢您的帮助
【问题讨论】:
-
有证书加密。
标签: sql-server-2005 encryption-asymmetric encryption-symmetric