CREATE ASYMMETRIC KEY Asym_EPassword
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = testdemo123
我已经Password
用上面的加密非对称密钥加密了我的表的一列。
现在我想解密查询中的password
列select
谁能建议如何做到这一点?
CREATE ASYMMETRIC KEY Asym_EPassword
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = testdemo123
我已经Password
用上面的加密非对称密钥加密了我的表的一列。
现在我想解密查询中的password
列select
谁能建议如何做到这一点?
SELECT CONVERT(NVARCHAR(100),
DecryptByAsymKey(AsymKey_ID('Asym_EPassword'),
YourColumn, 'testdemo123')) AS PlainText
FROM YourTable;
SQLFiddle don't let users create asymmetric keys, so for demo copy/paste this to your own 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!'));