Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ASP Binary to string

Featured Replies

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 DB

When I perform the check on the two strings

if BinaryToString = request.form("password") then valid=1

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

End Function


%>

<head>
<title>Validation</title>
</head>

<body>
<%

Dim conn2
Set 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 temppass
Dim valid
valid=0

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


  • Author

Im getting a little closer.

If I do

response.write(len(BinaryToString))
response.write(len(request.form("password")))

I get 50 and 8

If 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 :thumbup

My solution

Ive 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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.