CREATE ASYMMETRIC KEY Asym_EPassword
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = testdemo123
我已使用上述加密非对称密钥加密了我的表格的Password
列。
现在我要解密password
查询
select
列
有人可以建议怎么做吗?
答案 0 :(得分:1)
SELECT CONVERT(NVARCHAR(100),
DecryptByAsymKey(AsymKey_ID('Asym_EPassword'),
YourColumn, 'testdemo123')) AS PlainText
FROM YourTable;
SQLFiddle不允许用户创建非对称密钥,因此将其复制/粘贴到您自己的SSMS:
CREATE ASYMMETRIC KEY Asym_EPassword
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = 'testDemo123!'
DECLARE @PlainText NVARCHAR(100)
DECLARE @CipherText VARBINARY(MAX)
SET @PlainText = 'AAAAA'
SELECT @CipherText = EncryptByAsymKey(AsymKey_ID('Asym_EPassword'), @PlainText);
SELECT @CipherText;
SELECT CONVERT(NVARCHAR(100), DecryptByAsymKey(AsymKey_ID('Asym_EPassword'), @CipherText, N'testDemo123!'));