Taggs Posted September 7, 2006 Share Posted September 7, 2006 I have a simple login page that passes the username and password to a validation page.The password is stored as Binary in an SLQ2000 DBWhen I perform the check on the two strings if BinaryToString = request.form("password") then valid=1it always comes back as valid=0 if you display the two values they are the same. I suspect there are control chars on the end of the string.Can anyone help please.<html><%Function BinaryToString(Binary,valid) 'SimpleBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string) 'to a string (BSTR) using MultiByte VBS functions Dim I, S valid=0 For I = 1 To LenB(Binary) S = S & Chr(AscB(MidB(Binary, I, 1))) Next BinaryToString = S if BinaryToString = request.form("password") then valid=1End Function%><head><title>Validation</title></head><body><%Dim conn2Set conn2 = Server.CreateObject("ADODB.Connection")conn2.Open "DSN=Serverdetails; User Id = Administrator; Password=******"Sqlgetuser="select * from users where Username='" & request.form("username") & "'" set rs = conn2.execute(sqlgetuser)Dim temppassDim validvalid=0temppass = BinaryTostring(rs("password"),valid)if rs.eof then response.write("User " & request.form("username") & " not found!") session("password") = "" session("username") = ""elseif valid=1 then session("user") = request.form("username") session("permissions") = rs("permissions") Response.Redirect("/index.htm")else response.write("Password incorrect!") session("password") = "" session("username") = ""end if%></body></html> Link to comment Share on other sites More sharing options...
Taggs Posted September 7, 2006 Author Share Posted September 7, 2006 Im getting a little closer.If I do response.write(len(BinaryToString))response.write(len(request.form("password")))I get 50 and 8If I do response.write("B= " & Ascb(MidB(Binary, I, 1)) & " : ")if len(request.form("password")) >= i then response.write("P = " & Ascb(MidB(trim(request.form("password")), I, 1)) & " | ")I get B= 112 : P = 112 | B= 97 : P = 0 | B= 115 : P = 97 | B= 115 : P = 0 | B= 119 : P = 115 | B= 111 : P = 0 | B= 114 : P = 115 | B= 100 : P=0 | B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : B= 0 : the password box is passing a null (or 0) value and the binary string has trailing nulls (or 0's)Sorted My solutionIve changed S = S & Chr(AscB(MidB(Binary, I, 1)))to if Chr(AscB(MidB(Binary, I, 1))) <> Chr(0) then S = S & Chr(AscB(MidB(Binary, I, 1)))end if Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now