VerifySignedByAsymKey()不返回预期值

时间:2012-01-07 09:35:29

标签: sql-server sql-server-2008 encryption encryption-asymmetric

我正在玩Asymmetric Encryption and Decryption,但我不理解使用VerifySignedByAsymKey()时得到的结果。

为什么这样:

CREATE ASYMMETRIC KEY myasymkey 
WITH ALGORITHM = RSA_2048 
ENCRYPTION BY PASSWORD = '123pass!'; 
GO

Select VerifySignedByAsymKey(AsymKey_ID('myasymkey'), 
    'Greg', 
    EncryptByAsymKey(AsymKey_ID('myasymkey'), 'Greg'));
GO

制作0?我原以为1

1 个答案:

答案 0 :(得分:0)

您只加密了数据,未签名。

请参阅SignByAsymKey()。以下示例返回1:

declare @clear varchar(128)
set @clear = 'Greg'
Select VerifySignedByAsymKey(AsymKey_ID('myasymkey'), @clear, 
       SignByAsymKey(AsymKey_ID('myasymkey'), @clear, N'123pass!'))