April 20, 2010 at 11:38 am
Hi
Please help me. I want to do encryption/Decyption, i am giving examples
Example: http://www.google.com/Search/Test
Here i want to encrypt the only Test in this Url .After encrypting that should be like
http://www.google.com/Search/any encypted values(12we?12) and after decrytion that should ibe in origional form(www.google.com/Search/Test)
Note: In Sql Server2008/2005 i am unable to convert Varbinary to Varchar
Thanks
April 20, 2010 at 11:49 am
for encryption, i really like this article; lots of example,s and easy to follow along:
you know you have to encrypt the entire string, and not just part of it right?
so for your url example,
if not exists(SELECT * FROM sys.certificates WHERE name ='ElmerEncryptionCertificate')
BEGIN
CREATE CERTIFICATE ElmerEncryptionCertificate
WITH
SUBJECT = 'Elmer Certificate',
EXPIRY_DATE = '01/01/2011 '
PRINT '"Elmer Certificate" Created.'
END
ELSE
BEGIN
PRINT '"Elmer Certificate" Already Exists.'
END
DECLARE @encryptedstuff NVARCHAR(100)
SELECT @encryptedstuff = EncryptByCert(Cert_ID('ElmerEncryptionCertificate'), N'www.google.com/Search/Test')
SELECT @encryptedstuff
SELECT CAST(DecryptByCert(Cert_ID('ElmerEncryptionCertificate'), @encryptedstuff) AS NVARCHAR)
http://www.google.com/Search/Test
--becomes stuff that's not even readable
??????????????????????????????????????????????????Y?????????????
Lowell
April 20, 2010 at 1:24 pm
Thanks for the reply..But the result is in some Ascii or Sybolic form ...I require this encrypted value in Guid form.I can generate using Key_guid but it is Varbinary data here i cant convert into Varchar.
Please see again example : I have to encrypt the Part of the URI . In http://www.google.com/Search/Test here i have to encrypt Test only.if i use Key_Guid then it will be encrypted in GUID form but i am unable concatenat this encrypted value with http://www.google.com/Search because it is varchar.
April 20, 2010 at 2:45 pm
you'll need to paste the exact code you are using; encrypting part of a string, then concatenating the decrypted results is easy, so it's probably something fairly basic that is tripping you up.
Lowell
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply