I have a string:
strSQL="Update Employees Set Password='"&str&"' Where email='"&uname&"'"
str is the text the user types and run through the following functions:
str=hash(userinput)
Function hash(input)
Dim md5
Set md5=Server.CreateObject("MD5DLL.Crypt"
hash=newstr(md5.Encrypt(CStr(newstr(md5.Encrypt(CStr(input))))))
End Function
Function newstr(str)
Dim tempstr
tempstr=Replace(str, "../", ""
tempstr=Replace(tempstr, "--", ""
tempstr=Replace(tempstr, ";", ""
tempstr=Replace(tempstr, CHR(34),"""
newstr=Replace(tempstr, "'", "''"
End Function
Usually this works fine, but when a user types in certain strings, the double hash function sometimes returns strange values such and the strSQL results in:
Update Employees Set Password=dÉÖ"
and throws an ASP error. If I look at the html source I get:
Update Employees Set Password=dÉÖ"
so I know the newstr function is replacing the quote symbol with the ampersand-quot equivalent. Why is the string being terminated prematurely?
I have tried brackets and double quotation marks, but the string still gets chopped off. Any ideas? Thanks.
strSQL="Update Employees Set Password='"&str&"' Where email='"&uname&"'"
str is the text the user types and run through the following functions:
str=hash(userinput)
Function hash(input)
Dim md5
Set md5=Server.CreateObject("MD5DLL.Crypt"
hash=newstr(md5.Encrypt(CStr(newstr(md5.Encrypt(CStr(input))))))
End Function
Function newstr(str)
Dim tempstr
tempstr=Replace(str, "../", ""
tempstr=Replace(tempstr, "--", ""
tempstr=Replace(tempstr, ";", ""
tempstr=Replace(tempstr, CHR(34),"""
newstr=Replace(tempstr, "'", "''"
End Function
Usually this works fine, but when a user types in certain strings, the double hash function sometimes returns strange values such and the strSQL results in:
Update Employees Set Password=dÉÖ"
and throws an ASP error. If I look at the html source I get:
Update Employees Set Password=dÉÖ"
so I know the newstr function is replacing the quote symbol with the ampersand-quot equivalent. Why is the string being terminated prematurely?
I have tried brackets and double quotation marks, but the string still gets chopped off. Any ideas? Thanks.