January 20, 2009 at 5:43 pm
i have a table with
testtable
var1 int pk,
prize_id int
prize_encrypt varbinary
i am storing encrypted value of prizE_id in prize_encrypt
by the following statement.
DECLARE @pass VARCHAR(50)
SET @pass = 'WOhPorN5VIKZl$Eqcz4CR104O'
DECLARE @prize_encrypt VARBINARY(256)
Set @prize_encrypt = EncryptByPassphrase(@pass,Cast(@prize_id as varbinary))
values are
12sdf2342sdgdh243gdfb3445
21dfgkfgjh94334fghfdghi95
32sdf2342sdgdh243gdfb3445 (repating as first record)
in order to aviod repeation
DECLARE @pass VARCHAR(50)
DECLARE @prize_pass VARCHAR(50)
SET @pass = 'WOhPorN5VIKZl$Eqcz4CR104O'
DECLARE @prize_encrypt VARBINARY(256)
SELECT @maxval=IDENT_CURRENT('testtable') +1
set @prize_id_pass = @pass +','+CAST(@maxval AS VARCHAR)
Set @prize_encrypt = EncryptByPassphrase(@prize_pass,Cast(@prize_id as varbinary))
Encrypting is in one stroed proc..
and decryption is in another stored proc..
the above one is working with out repeating..
but now if i try to decrypt the prize_encrypt i am getting null value.
DECLARE @pass VARCHAR(50)
DECLARE @prize_pass VARCHAR(50)
SET @pass = 'WOhPorN5VIKZl$Eqcz4CR104O'
DECLARE @prize_encrypt VARBINARY(256)
SELECT CAST(DecryptByPassphrase(@prize_pass, prize_encrypt) AS varchar) as val2
from testtable
i am getting NULL value if i do like this..
please help me on this..
January 21, 2009 at 12:17 am
Please don't cross post. It just wastes peoples time and fragments replies.
No replies to this thread please. Direct replies to: http://www.sqlservercentral.com/Forums/Topic640326-149-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply