我正在使用我创建的存储过程:
USE [database_name]
GO
OPEN SYMMETRIC KEY Password_Key
DECRYPTION BY CERTIFICATE PasswordCertificate;
GO
CREATE PROCEDURE dbo.AddPassword
@ID int,
@Password varchar(50)
WITH ENCRYPTION
AS
INSERT INTO .EncryptionTest (ID,Password,Password_Encrypted)
VALUES (@ID,@Password,EncryptByKey(Key_GUID('Password_Key')
, @Password, 1, HashBytes('SHA1', CONVERT(varbinary,@ID))))
GO
并且在执行时:
USE [database_name]
GO
EXEC dbo.AddPassword @ID = 1, @Password = 'Test';
GO
它添加了一行ID
= 1, Password
= 'Test', Password_Encrypted
= NULL。为什么最后一个给出null而不是字符串'Test'的加密?