You are here: Re: SQL 2005 Encryption questions « MsSQL Server « IT news, forums, messages
Re: SQL 2005 Encryption questions

Posted by rcamarda on 04/27/06 01:12

Update:
I can get this to work on static data:

CREATE ASYMMETRIC KEY Student_aKey
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = 'Th1ssuck5'

DECLARE @encryptedstuff NVARCHAR(250)
set @encryptedstuff = EncryptByAsymKey(AsymKey_ID('Student_aKey'),
N'That''s all folks')
SELECT @encryptedstuff
SELECT CAST( DecryptByAsymKey(AsymKey_ID('Student_aKey'),
@encryptedstuff,N'Th1ssuck5' ) AS NVARCHAR)
SELECT CAST( DecryptByAsymKey(AsymKey_ID('Student_aKey'),
EncryptByAsymKey(AsymKey_ID('Student_aKey'), N'That''s all
folks'),N'Th1ssuck5' ) AS NVARCHAR)


However when I use these tecniques on my table, I can not decrypt the
data. So I thought I would emulate the encryption, decryption with the
following:
select
cast(DecryptByAsymKey(AsymKey_ID('Student_aKey'), estudent_ssn,
N'Th1ssuck5') as nvarchar(100))
from (
SELECT
cast(EncryptByAsymKey(AsymKey_ID('Student_aKey'), 'supercalifragi') as
nvarchar(100)) AS eSTUDENT_SSN
) as xx

which does not work.
While I was composing this email, I thought I would put a N in front of
my literal:
select
cast(DecryptByAsymKey(AsymKey_ID('Student_aKey'), estudent_ssn,
N'Th1ssuck5') as nvarchar(100))
from (
SELECT
cast(EncryptByAsymKey(AsymKey_ID('Student_aKey'), N'supercalifragi') as
nvarchar(100)) AS eSTUDENT_SSN
) as xx
which worked.
What is the N in front of the literal 'supercalifragi' do? is it a
shortcut for cast(xxx as nvarchar())??

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация