Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Question Unanswered: comparing encrypted strings

    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) = 1

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    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
    -----------

  3. #3
    Join Date
    Oct 2003
    Posts
    3

    Thnx

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

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Thnx

    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.

  5. #5
    Join Date
    Oct 2003
    Posts
    3

    Re: Thnx

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •