Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > Files > Encode / Decode > MD5 Checksums

Calculate MD5 Checksums

 

X-MD5
VBScript Code:
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
Requirements:
Windows version: any
Network: any
Client software: X-MD5 component
Script Engine: any
Summarized: Works in any Windows version with the X-MD5 component installed.
 
[Back to the top of this page]

page last modified: 2016-09-19; loaded in 0.0028 seconds