Dubie
09.04.2005, 03:44
Sup all,
Trying to allow users from the DB to login and see misc stuff about thier Chars & Accounts
Ok, I'm having some real problems with this script .
I'll try to keep it as simple as I can.
I'm doing an authentication script, the complication lies in that the passwords I need to authenticate are stored in the SQL database as binary objects.
I've successfully hunted down several functions that convert binary data to string, so that I can compare with form input.
However, it seems the database is Korean, or something, because the output looks like this when I convert from binary to string form:
5ÀáuÄk´¥ ˆ Oˆw»»
Not sure what is going wrong here at all.
This is what I need some help on.
However the password is (originally) in english...
So, is there any way without a component to convert that to normal charset? A couple of the functions had a charset option, I tried 'us-ascii' and 'utf-8' but neither worked.
Any help is appreciated, if more details are needed, here's all the functions I tried below:
Function Stream_BinaryToString(Binary, CharSet)
Const adTypeText = 2
Const adTypeBinary = 1
'Create Stream object
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To save text/string data.
BinaryStream.Type = adTypeBinary
'Open the stream And write text/string data To the object
BinaryStream.Open
BinaryStream.Write Binary
'Change stream type To binary
BinaryStream.Position = 0
BinaryStream.Type = adTypeText
'Specify charset For the source text (unicode) data.
If Len(CharSet) > 0 Then
BinaryStream.CharSet = CharSet
Else
BinaryStream.CharSet = "us-ascii"
End If
'Open the stream And get binary data from the object
Stream_BinaryToString = BinaryStream.ReadText
End Function
Function BinToText(varBinData, intDataSizeInBytes) ' as String
Const adFldLong = &H00000080
Const adVarChar = 200
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk varBinData
BinToText = objRS("txt").Value
objRS.Close
Set objRS = Nothing
End Function
Function BinaryToString(Binary)
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
We can change anyone password that is not a problem, its trying to compare it to the old one that is stoping us for allowing ppl to login that are players in the DB.
Would appreciate any input on this problem
Thanks for your time,
Dubie
Trying to allow users from the DB to login and see misc stuff about thier Chars & Accounts
Ok, I'm having some real problems with this script .
I'll try to keep it as simple as I can.
I'm doing an authentication script, the complication lies in that the passwords I need to authenticate are stored in the SQL database as binary objects.
I've successfully hunted down several functions that convert binary data to string, so that I can compare with form input.
However, it seems the database is Korean, or something, because the output looks like this when I convert from binary to string form:
5ÀáuÄk´¥ ˆ Oˆw»»
Not sure what is going wrong here at all.
This is what I need some help on.
However the password is (originally) in english...
So, is there any way without a component to convert that to normal charset? A couple of the functions had a charset option, I tried 'us-ascii' and 'utf-8' but neither worked.
Any help is appreciated, if more details are needed, here's all the functions I tried below:
Function Stream_BinaryToString(Binary, CharSet)
Const adTypeText = 2
Const adTypeBinary = 1
'Create Stream object
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To save text/string data.
BinaryStream.Type = adTypeBinary
'Open the stream And write text/string data To the object
BinaryStream.Open
BinaryStream.Write Binary
'Change stream type To binary
BinaryStream.Position = 0
BinaryStream.Type = adTypeText
'Specify charset For the source text (unicode) data.
If Len(CharSet) > 0 Then
BinaryStream.CharSet = CharSet
Else
BinaryStream.CharSet = "us-ascii"
End If
'Open the stream And get binary data from the object
Stream_BinaryToString = BinaryStream.ReadText
End Function
Function BinToText(varBinData, intDataSizeInBytes) ' as String
Const adFldLong = &H00000080
Const adVarChar = 200
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk varBinData
BinToText = objRS("txt").Value
objRS.Close
Set objRS = Nothing
End Function
Function BinaryToString(Binary)
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
We can change anyone password that is not a problem, its trying to compare it to the old one that is stoping us for allowing ppl to login that are players in the DB.
Would appreciate any input on this problem
Thanks for your time,
Dubie