How do you compare an encripted value to a string?
I have a table called test table which has a column called password. The fields in that column were encrypted using the pwdencrypt() function. I need to be able to compare those encrypted fields to regular nvarchar strings. Right now I am using the pwdcompare() function to compare the values but I'm not getting the desired results.
This is what I am doing
select *
from testtable
where pwdcompare(pwdencrypt('pass_tempx'),testtable.pass word) = 1Check this one:
create table users(
id int identity,
username nvarchar(128) not null unique,
userpassword nvarchar(128) not null
)
insert users(username,userpassword)
select 'tom',pwdencrypt('tom2')
insert users(username,userpassword)
select 'brett',pwdencrypt('brett2')
select Id from users
where pwdcompare('tom2',userpassword)=1
and username='tom'
Id
----
1
(1 row(s) affected)
select Id from users
where pwdcompare('brett3',userpassword)=1
and username='brett'
Id
----|||Thanks for the feedback but it still isn't working for me. I've got my table set up just like yours but my username and userpassword fields are set up as nvarchar(15). Does this make a difference? Is there any other way to compare the 2 strings?
Originally posted by snail
Check this one:
create table users(
id int identity,
username nvarchar(128) not null unique,
userpassword nvarchar(128) not null
)
insert users(username,userpassword)
select 'tom',pwdencrypt('tom2')
insert users(username,userpassword)
select 'brett',pwdencrypt('brett2')
select Id from users
where pwdcompare('tom2',userpassword)=1
and username='tom'
Id
----
1
(1 row(s) affected)
select Id from users
where pwdcompare('brett3',userpassword)=1
and username='brett'
Id
----|||Originally posted by grualo1
Thanks for the feedback but it still isn't working for me. I've got my table set up just like yours but my username and userpassword fields are set up as nvarchar(15). Does this make a difference? Is there any other way to compare the 2 strings?
MS is using nvarchar(128) for keeping a passwors and I guess functions pwdcompare and pwdencrypt are working only for this length of string.|||Changing the length to 128 did the trick thank you so much!
Gary
Originally posted by snail
MS is using nvarchar(128) for keeping a passwors and I guess functions pwdcompare and pwdencrypt are working only for this length of string.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment