So ... if you can find that old VB6 function, yes, it can be re-used or translated. If not ... you're out of luck.
Main Topics
Browse All TopicsI have a legacy app I've just been given to maintian/enhance before a full .Net upgrade. The app is written with tradisional ASP, VB 6 dll's and SQL Server 2000. I'm trying to add functionality that will allow the users to reset a forgotten password. I have that basically set up now (with help from Experts). The last problem with it lies in the password itself. It is encrypted (sha algorithm). When the system goes to change the password it needs to encrypt it. In the past a VB 6 function called HashString was used. Is there a way to convert/use that function is ASP? Or create a stored procedure that encrypts it? Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Copy the function as is to a .asp page. Then you only have to remove the datatypes declarations and see if it works:
"byVal s As String" should be "byVal s" only in ASP, "Dim i as Integer" should be "Dim i" in ASP and so on.
If an error occurs when running the function you should be able to fix it or you can post the code and errror here.
Here is the HashString function I'm trying to get to work in the ASP page. I'm getting an error at Redim pBuffer. It's says expected ')'.
Private Function HashString(lInVal)
Dim bResult
Dim hHash
Dim hKey
Dim txt
Dim hProv
Dim txtres
Dim dwBuffsize(4)
Dim dwSize
Dim pBuffer()
Dim pbBuff
Dim pbBuffSize
Dim stres(100)
Dim stsrc
Dim hHeap
Dim pStRes
HashString = ""
hHeap = GetProcessHeap()
pbBuffsize = HeapAlloc(hHeap, 0, 4)
bResult = CryptAcquireContext(VarPtr
bResult = CryptCreateHash(hProv, CALG_SHA1, 0, 0, hHash)
bResult = CryptHashData(hHash, lInVal, Len(lInVal), 0)
bResult = CryptGetHashParam(hHash, HP_HASHSIZE, pbBuffSize, 4, 0)
ReDim pBuffer(0 To pbBuffSize - 1)
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pBuffer(0), pbBuffSize, 0)
Dim x
Dim strOut
For x = 0 To UBound(pBuffer)
If pBuffer(x) <= &HF Then
strOut = strOut & "0" & Hex(pBuffer(x))
Else
strOut = strOut & Hex$(pBuffer(x))
End If
Next
HashString = strOut
bResult = CryptDestroyHash(hHash)
bResult = CryptReleaseContext(hProv,
Exit Function
End Function
There are no pointers in ASP/VBScript and no access to API. You can compile to ActiveX-DLL (add class with this function) and register on web server to access the function.
Here some helpful links:
http://support.microsoft.c
http://support.microsoft.c
Yes, it is an ActiveX .dll already regsitered on the server. The .dll is called AddUser.dll, created from a visual basic project call AddUser.vbp. The HashString Function exists in this .dll. The new ASP page needs to call that function when it executes a SQL statement. Here is what the code looks like in the ASP page right now that executes the SQL:
uSQL = "UPDATE [Accounts] SET [Password] = '" & HashString(Trim(strPasswor
"ChgPassword = 1, & _
"WHERE UserID=" & userid
myConn.Execute uSQL
So in the ASP page, I need to utilize something like was suggested?
dim c
set c = server.createobject("AddUs
dim hash = c.HashString("somedata")
I'm not sure I follow completely.
OK, I think I'm tracking now. I tried this:
dim c
set c = server.createobject("AddUs
dim hash = c.HashString(Trim(strPassw
uSQL = "UPDATE [Accounts] SET [Password] = '" & hash & "', " & _
"ChgPassword = 1, & _
"WHERE UserID=" & userid
myConn.Execute uSQL
but i get this error: Expected end of statement line 28 column 9
Dim hash = c.HashString(Trim(strPassw
This I tried it like this:
dim c
dim hash
set c = server.createobject("AddUs
set hash = c.HashString(Trim(strPassw
uSQL = "UPDATE [Accounts] SET [Password] = '" & hash & "', " & _
"ChgPassword = 1, & _
"WHERE UserID=" & userid
myConn.Execute uSQL
and got this error:
Object does not support this property or method" 'HashString'.
Like I said, I'm using a function (HashString) that is in a .dll that is registered, as it is used elsewhere in this app. Any ideas?
angelIII, once again, thanks for the help. My code now looks like this:
Dim c
Set c = Server.CreateObject("AddUs
Dim hash
hash = c.HashString(Trim(strPassw
uSQL = "UPDATE [Accounts] SET [Password] = '" & hash & "', " & _
"ChgPassword = 1, & _
"WHERE UserID=" & userid
myConn.Execute uSQL
I still get the same error:
Object doesn't support this property or method: 'HashString'
Could I not be referring to the project/dll correctly? The project is AddUser.vbp. The project name is AddUser. WebClass1 is under designers, though. Not Class modules. Any ideas?
Business Accounts
Answer for Membership
by: angelIIIPosted on 2009-07-07 at 13:32:53ID: 24798138
trying to find the implementation of the hashstring function in the old application is required here.
otherwise, if you used a new function, a different hash from the password would be generated, which would invalidate all the existing password...