Encryption By Certificate

Posted by user1817240 on Stack Overflow See other posts from Stack Overflow or by user1817240
Published on 2012-11-12T04:50:44Z Indexed on 2012/11/12 4:59 UTC
Read the original article Hit count: 142

Filed under:
|
|

I am encrypting customer name in database at database level. While saving in database only first letter of customer name is saved and hence while decrypting only first letter is retrieved.

The following code shows the test sp.

ALTER PROCEDURE  [dbo].[spc_test_insert] ( 
@sFIRST_NAME typ_encryptedtext, 
) 
AS 
BEGIN 

DECLARE @sSENCRYPTION_KEY char(15) 
DECLARE @sCERTIFICATE char(22) 



SET @sSENCRYPTION_KEY='SymmetricKey1' 
SET @sCERTIFICATE='CustomerCertificate' 


OPEN SYMMETRIC KEY SymmetricKey1 
DECRYPTION BY CERTIFICATE CustomerCertificate; 
INSERT INTO test_table ( 
FIRST_NAME, 
 ) Values ( 
 -- Add the Params to be Added... 
EncryptByKey(Key_GUID(@sSENCRYPTION_KEY),@sFIRST_NAME), 
) 
CLOSE SYMMETRIC KEY SymmetricKey1 
END

encryption decryption working fine in normal insert but its not working in stored procedure.

© Stack Overflow or respective owner

Related posts about encryption

Related posts about certificate