|
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]
|