Hello,
I have a script that successfully encrypts a credit card. I need it to work as a trigger, so that any insert done to the creditcard column automatically encrypts it. Right now, my trigger works BUT the creditcard column is a varchar. When an app tries to insert, I do this:
DECLARE @encryptedCreditCardNumber varbinary(max) SET @encryptedCreditCardNumber = EncryptByKey(Key_GUID('testKey'), @CreditCardNumber));
That works fine, but how do I then convert the varbinary(max) to a varchar (which is what the credit card column is). The creditcard column has been a varchar for a long time at my company and a lot of legacy code depends on it being a varchar.
Thank you