USE AdventureWorks2012;
GO
-- Create a column in which to store the encrypted data.
ALTER TABLE HumanResources.Employee
ADD EncryptedNationalIDNumber varbinary(128);
GO
-- Open the symmetric key with which to encrypt the data.
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
-- Encrypt the value in column NationalIDNumber with symmetric key
-- SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
UPDATE HumanResources.Employee
SET EncryptedNationalIDNumber
= EncryptByKey(Key_GUID('SSN_Key_01'), NationalIDNumber);
GO
1条答案
按热度按时间6za6bjd01#
你可能在找
ENCRYPTBYKEY
在sql server上,例如:使用的加密算法取决于提供的密钥,因此您需要使用
CREATE SYMMETRIC KEY
创建用于AES-256
算法,例如: