Vbscript string to MD5 hexidecimal hash

Experts:

I have a need to script out the hashing of a string to MD5 to do a comparison against a hashed value in a database.  I do not want to have to use any external EXE to perform this action and VBscript/Jscript are the only languages I can use on this particular project.

I've managed to find a lot of information on the MD5 hashing and classes available in .NET 3.5, but have yet been able to perform the hash and view the hexidecimal output.

Here is a link to MSDN's document on MD5 class:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5cryptoserviceprovider.aspx

Any ideas?
LVL 12
piattndAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sr75Commented:
Can you use a library??  I use a library I found called XMD5.dll.  It works pretty good in my scripts.  
0
piattndAuthor Commented:
I might be able to register/unregister it.  Can you throw me the DLL and instructions on how you used it?
0
sr75Commented:
Here is a link to the file and it also has some instructions on how to use it:

http://www.xstandard.com/en/documentation/xmd5/


WScript.Echo "Comparing 2 strings:"
strString = "Meet John Doe"
WScript.Echo "MD5 Checksum for """ & strString _
           & """: " & GetStringCheckSum( strString )
strString = "meet John Doe"
WScript.Echo "MD5 Checksum for """ & strString _
           & """: " & GetStringCheckSum( strString )
WScript.Echo
WScript.Echo "Comparing 2 files:"
strFile1 = "C:\WINDOWS\System32\wmpcore.dll"
strFile2 = "C:\WINDOWS\System32\dllcache\wmpcore.dll"
WScript.Echo "MD5 Checksum for " & strFile1 _
           & ":          " & GetFileCheckSum( strFile1 )
WScript.Echo "MD5 Checksum for " & strFile2 _
           & ": " & GetFileCheckSum( strFile2 )



Function GetFileCheckSum( myFile )
' This function uses X-standards.com's X-MD5 component to calculate
' the MD5 checksum of a file.
'
' Argument:
' myFile [string] the file name whose checksum is to be calculated
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
'
' The X-MD5 component is available at:
' http://www.xstandard.com/page.asp?p=C8AACBA3-702F-4BF0-894A-B6679AA949E6
' For more information on available functionality read:
' http://www.xstandard.com/printer-friendly.asp?id=44AFBB03-EDC1-49FE-94CC-333AE728331E
    Dim objMD5
    Set objMD5 = CreateObject( "XStandard.MD5" )
    GetFileCheckSum = objMD5.GetCheckSumFromFile( myFile )
    Set objMD5 = Nothing
End Function


Function GetStringCheckSum( myString )
' This function uses X-standards.com's X-MD5 component to calculate
' the MD5 checksum of a string.
'
' Argument:
' myString [string] the string whose checksum is to be calculated
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
'
' The X-MD5 component is available at:
' http://www.xstandard.com/page.asp?p=C8AACBA3-702F-4BF0-894A-B6679AA949E6
' For more information on available functionality read:
' http://www.xstandard.com/printer-friendly.asp?id=44AFBB03-EDC1-49FE-94CC-333AE728331E
    Dim objMD5
    Set objMD5 = CreateObject( "XStandard.MD5" )
    GetStringCheckSum = objMD5.GetCheckSumFromString( myString )
    Set objMD5 = Nothing
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piattndAuthor Commented:
Thank you very much for the thorough VBS code example and the DLL.  I was able to take what you gave and turn it into exactly what I need!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.