-
Encryption SP question
I have a table with credit card numbers. I need to encrypt the CC numbers. Since the encryption value is larger than the existing varchar(16) currently used, I will modify the schema so that the CC number is varchar(256).
Now, I have some code that I have tested that uses my RSA object from a query to perform the encryption. Here is that code:
set @method_call = 'EncryptStringENC("' + @cc_number + '",0)' -- ' + @usePrivateKey + ')'
EXEC @rc=sp_OAMethod @RSA_Object, @method_call, @cc_number_encrypted out
if @rc <> 0 -- If error spew it and exit
begin
exec sp_oageterrorinfo @RSA_Object, @src out, @desc out
select hr=convert(varbinary(4),@rc), source=@src, description=@desc
return
end
My question is, how do I write some SQL that will allow me to read the existing CC number from the table and update it to the new encrypted version.
There is about 1M records so I was going to implement this as an SP. In the code above, @cc_number would contain the CC number from the DB and @cc_number_encrypted would contain the encrypted number that I want to update back to the database in the same record that the unencrypted CC number originated from.
All of the encryption code has been tested and works just fine - I just need to understand how to incorporate an update with this code to do the updates back to the table.
Thanks!
-
Well since no one has an answer, I will answer this myself:
Convert the SP to a scalar function.
Call the function from within an update query.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|