1
Answer

How to decrypt a encrypted password which is in varbinary in SQL Server 2005?

How to decrypt a encrypted password which is in varbinary in SQL Server 2005?

I have field called pasword  varbinary(50). While inserting the data :

insert into sometable values(pwdencrypt(pasword)) it's working fine.

The problem is when I am comparing the password with the pwdcompare(@oldpwd,@curPwd) method each time it's returning false. So how to compare the old password in sql server 2005.

The sample code is given below

begin

declare @cmp int

declare @result varbinary(50)

declare @pwd varbinary(50)

set @result = convert(varbinary(50),pwdencrypt('test'))

set @pwd= convert(varbinary(50),pwdencrypt('test'))

set @cmp=pwdcompare(@result,@pwd)

if(@cmp=1)

begin

print 'true'

end

else

begin

print 'false'

end

end

Each time it's prints false after passing the same value also.

Answers (1)