Encryption - decryption using French words in SQl Server 2008

I want to add a French word similar Catégoriesin my table, p EncryptByKey. Here is my request:

OPEN SYMMETRIC KEY SymmetricKey1
DECRYPTION BY CERTIFICATE Certificate1;
insert into tbl_Name (Name)
values (EncryptByKey( Key_GUID('SymmetricKey1'), CONVERT(Nvarchar,'Catégories')))

but when I get the value with the following query, I got 慃㽴潧楲獥insteadCatégories

OPEN SYMMETRIC KEY SymmetricKey1
DECRYPTION BY CERTIFICATE Certificate1;
SELECt CONVERT(NVARCHAR(max),DECRYPTBYKEY(Name)) as Name from tbl_Name 

could you help me?

+3
source share
2 answers

Write French words with the prefix " N" to mark the string as Unicode and then encrypt:

insert into tbl_Name (Name)
values (EncryptByKey( Key_GUID('SymmetricKey1'), N'Catégories'))
0
source

, , UNICODE. , , , , , , , , .

:

OPEN SYMMETRIC KEY SymmetricKey1
DECRYPTION BY CERTIFICATE Certificate1;

insert into tbl_Name (Name)
values (EncryptByKey( Key_GUID('SymmetricKey1'), N'Catégories'))

N , Unicode .

0

All Articles