Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for xmd5demo.vbs

(view source code of xmd5demo.vbs as plain text)

  1. WScript.Echo "Comparing 2 strings:"
  2. strString = "Meet John Doe"
  3. WScript.Echo "MD5 Checksum for """ & strString & """: " & GetStringCheckSum( strString )
  4. strString = "meet John Doe"
  5. WScript.Echo "MD5 Checksum for """ & strString & """: " & GetStringCheckSum( strString )
  6. WScript.Echo
  7. WScript.Echo "Comparing 2 files:"
  8. strFile1 = "C:\WINDOWS\System32\wmpcore.dll"
  9. strFile2 = "C:\WINDOWS\System32\dllcache\wmpcore.dll"
  10. WScript.Echo "MD5 Checksum for " & strFile1 & ":          " & GetFileCheckSum( strFile1 )
  11. WScript.Echo "MD5 Checksum for " & strFile2 & ": " & GetFileCheckSum( strFile2 )
  12.  
  13.  
  14.  
  15. Function GetFileCheckSum( myFile )
  16. ' This function uses X-standards.com's X-MD5 component to calculate
  17. ' the MD5 checksum of a file.
  18. '
  19. ' Argument:
  20. ' myFile [string] the file name whose checksum is to be calculated
  21. '
  22. ' Written by Rob van der Woude
  23. ' http://www.robvanderwoude.com
  24. '
  25. ' The X-MD5 component is available at:
  26. ' http://www.xstandard.com/page.asp?p=C8AACBA3-702F-4BF0-894A-B6679AA949E6
  27. ' For more information on available functionality read:
  28. ' http://www.xstandard.com/printer-friendly.asp?id=44AFBB03-EDC1-49FE-94CC-333AE728331E
  29. 	Dim objMD5
  30. 	Set objMD5 = CreateObject( "XStandard.MD5" )
  31. 	GetFileCheckSum = objMD5.GetCheckSumFromFile( myFile )
  32. 	Set objMD5 = Nothing
  33. End Function
  34.  
  35.  
  36. Function GetStringCheckSum( myString )
  37. ' This function uses X-standards.com's X-MD5 component to calculate
  38. ' the MD5 checksum of a string.
  39. '
  40. ' Argument:
  41. ' myString [string] the string whose checksum is to be calculated
  42. '
  43. ' Written by Rob van der Woude
  44. ' http://www.robvanderwoude.com
  45. '
  46. ' The X-MD5 component is available at:
  47. ' http://www.xstandard.com/page.asp?p=C8AACBA3-702F-4BF0-894A-B6679AA949E6
  48. ' For more information on available functionality read:
  49. ' http://www.xstandard.com/printer-friendly.asp?id=44AFBB03-EDC1-49FE-94CC-333AE728331E
  50. 	Dim objMD5
  51. 	Set objMD5 = CreateObject( "XStandard.MD5" )
  52. 	GetStringCheckSum = objMD5.GetCheckSumFromString( myString )
  53. 	Set objMD5 = Nothing
  54. End Function
  55.  

page last modified: 2024-04-16; loaded in 0.0066 seconds