Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. String comparison

String comparison

Scheduled Pinned Locked Moved Database
database
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    H he el el oooo
    wrote on last edited by
    #1

    In stored procedure i used a query "select Password from tblUser where username='User1' and password='Password' the reselt is 'Password' But at the backend the value of Password is 'password' (that is small letters. Since password validation needs case sensitive validation how am i supposed to used string comparator. Else is there any other option

    ItsMe

    N E R 3 Replies Last reply
    0
    • H H he el el oooo

      In stored procedure i used a query "select Password from tblUser where username='User1' and password='Password' the reselt is 'Password' But at the backend the value of Password is 'password' (that is small letters. Since password validation needs case sensitive validation how am i supposed to used string comparator. Else is there any other option

      ItsMe

      N Offline
      N Offline
      nguyenvhn
      wrote on last edited by
      #2

      If you are using SQL 2005, you can use HashBytes function to calculate a hashing value of password then compare two hashing values. If you use SQL 2000, you can use BINARY_CHECKSUM function instead of.

      H 1 Reply Last reply
      0
      • N nguyenvhn

        If you are using SQL 2005, you can use HashBytes function to calculate a hashing value of password then compare two hashing values. If you use SQL 2000, you can use BINARY_CHECKSUM function instead of.

        H Offline
        H Offline
        H he el el oooo
        wrote on last edited by
        #3

        I am using SQL 2000. i this function is quite complicated one. I just wanted to return true by comparing the below string string1='User1' string2='User1' string3='user1' (here the character 'u' is small) true when string1 and string2 are compared false when string 3 is compared with either string1 or string2

        ItsMe

        1 Reply Last reply
        0
        • H H he el el oooo

          In stored procedure i used a query "select Password from tblUser where username='User1' and password='Password' the reselt is 'Password' But at the backend the value of Password is 'password' (that is small letters. Since password validation needs case sensitive validation how am i supposed to used string comparator. Else is there any other option

          ItsMe

          E Offline
          E Offline
          Eric Dahlvang
          wrote on last edited by
          #4

          select Password from tblUser where username='User1' and cast(password as binary)=cast('Password' as binary) Run this little test in the SQL Query Analyzer:

          declare @cTest1 varchar(10)
          declare @cTest2 varchar(10)

          select @cTest1 = 'test'
          select @cTest2 = 'Test'

          if (@cTest1 = @cTest2)
          print 'They are equal as varchar'
          else
          print 'They are NOT equal as varchar'

          if (cast(@cTest1 as binary) = cast(@cTest2 as binary))
          print 'They are equal as binary'
          else
          print 'They are NOT equal as binary'

          --EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters

          1 Reply Last reply
          0
          • H H he el el oooo

            In stored procedure i used a query "select Password from tblUser where username='User1' and password='Password' the reselt is 'Password' But at the backend the value of Password is 'password' (that is small letters. Since password validation needs case sensitive validation how am i supposed to used string comparator. Else is there any other option

            ItsMe

            R Offline
            R Offline
            Rob Graham
            wrote on last edited by
            #5

            Your biggest problem is that you are storing plaintext passwords in a dababase table. Any hacker who compromises a single user login will have access to every username and password in the system...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups