October 8, 2013 at 4:05 am
Hi all,
I have a SQL Server which encrypt me / decrypts sensitive data in nvarchar column to binary one with insted of trigger.
When I try to decode them with same key, the sensitive data looks like that '2 '
Some ideas what happens ?
Best regards,
Krastio Kostov
October 8, 2013 at 9:05 am
Posting the SQL would be a good start buddy. We might be able to make some suggestions if we can see what your are actually trying to do.
October 9, 2013 at 4:29 am
Hi Loudy, everybody,
Thanks for the interest.
The SQL looks like that:
====================================================
=== Encrypting ===
-- Open symmetric key
open symmetric key UserKey decryption by password = 'P@ssw0rd'
---- Add encrypted data
insert into
[Target]
(Column1
,Column2)
select
Column11
,ENCRYPTBYKEY(key_guid('UserKey'),Column12,1,Column11)
from
[Source]
-- Close symmetric key
close symmetric key UserKey
====================================================
=== Decrypting ===
-- Open symmetric key
open symmetric key UserKey decryption by password = 'P@ssw0rd'
---- select decrypted data
select
Column1
,CONVERT(nvarchar(50),DECRYPTBYKEY(,Column2,1,Column1))
from
[Source]
-- Close symmetric key
close symmetric key UserKey
====================================================
Column11 = nvarchar(50)
Column12 = nvarchar(50)
Column1 = nvarchar(50)
Column2 = varbinary(max)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply