我有一个包含列,SSN和空列的表,SSNEncrypted Varbinary(MAX)。我这样做:
OPEN SYMMETRIC KEY SSNKey
DECRYPTION BY CERTIFICATE SSNCert;
UPDATE [dbo].[Customers]
SET [SSNEncrypted] = EncryptByKey(Key_GUID('SSNKey'), [dbo].[Customers].ssn);
CLOSE SYMMETRIC KEY SSNKey;
我可以确认ssn列包含值' 3xx-xx-xxxx'。但是当我做以下事情时:
OPEN SYMMETRIC KEY SSNKey
DECRYPTION BY CERTIFICATE SSNCert;
SELECT
CONVERT(VARCHAR, DecryptByKey( [SSNEncrypted]) ) as SSN_decrypted
FROM [dbo].[Customers]
CLOSE SYMMETRIC KEY SSNKey;
我的值为3.我认为它只给了我第一个数字。我在这做错了什么?