A small script to sumcheck the MUSHclient download

Posted by Nick Gammon on Sat 19 Aug 2006 04:42 AM — 5 posts, 30,388 views.

Australia Forum Administrator #0
Occasionally downloads fail, so this (Lua) script here lets you check the download of MUSHclient against a supplied MD5 hash.


name = utils.filepicker ("Choose file", "mushclient*.exe", "exe", 
                        { exe = "MUSHclient installers" } )

if name then
  f = io.open (name, "rb")
  if f then
    print ("sumcheck =", utils.tohex (utils.md5 (f:read ("*a"))))
    f:close () 
  end -- if opened file ok
end -- if have name


For example, run against mushclient378.exe (the installer itself) I got:


sumcheck = A6DB5E2A12B90344D30B9566A7FAB19D

Amended on Sat 19 Aug 2006 04:44 AM by Nick Gammon
Australia Forum Administrator #1
You can make an alias to do the same thing:


<aliases>
  <alias
   match="md5sum"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>name = utils.filepicker ("Choose file", "mushclient*.exe", "exe", 
                        { exe = "MUSHclient installers" } )

if name then
  f = io.open (name, "rb")
  if f then
    print ("sumcheck of", name, "=", utils.tohex (utils.md5 (f:read ("*a"))))
    f:close () 
  end -- if opened file ok
end -- if have name
</send>
  </alias>
</aliases>


Just type "md5sum" and it will prompt you for the file to check.
Australia Forum Administrator #2
And if you prefer not to use Lua as your main scripting language, just save the stuff below and make a plugin:

Template:saveplugin=Installer_sumcheck
To save and install the Installer_sumcheck plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as Installer_sumcheck.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Installer_sumcheck.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, August 19, 2006, 2:50 PM -->
<!-- MuClient version 3.78 -->

<!-- Plugin "Installer_sumcheck" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Installer_sumcheck"
   author="Nick Gammon"
   id="4a267cd69ba59b5ecefe42d8"
   language="Lua"
   purpose="Sumchecks the MUSHclient installer"
   date_written="2006-08-19 14:48:45"
   requires="3.74"
   version="1.1"
   >

<description trim="y">
* Type 'md5sum' to activate. 

* Navigate to the mushclientXXX.exe file you downloaded.
(The XXX will be the version number).

* Click 'Open'. 

The resulting message (in the output window) will show you the sumcheck.

This should agree with the sumcheck shown on the web page announcing the MUSHclient version.
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   match="md5sum"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>name = utils.filepicker ("Choose file", "mushclient*.exe", "exe", 
                        { exe = "MUSHclient installers" } )

if name then
  f = io.open (name, "rb")
  if f then
    print ("sumcheck of", name, "=", string.lower (utils.tohex (utils.md5 (f:read ("*a")))))
    f:close () 
  end -- if opened file ok
end -- if have name
</send>
  </alias>
</aliases>

<script>
ColourNote ("cyan", "", "Type 'md5sum' to sumcheck a file.")
</script>

</muclient>
Amended on Fri 30 Jul 2010 03:22 AM by Nick Gammon
Australia Forum Administrator #3
You may have problems running this if you have the default Lua "sandbox" as that disables files being read/written. To fix that, use the File menu -> Global Preferences -> Lua and search for the lines:


-- default is to sandbox everything --

MakeSandbox ()  --> remove this line to remove protection




Change that to:


-- sandbox everything except the installer sumcheck plugin --

if GetPluginID () ~= "4a267cd69ba59b5ecefe42d8" then -- Installer_sumcheck
  MakeSandbox ()  
end -- if

Australia Forum Administrator #4
An alternative approach is to download the md5sum program. Here are some locations where I found a copy. md5.zip includes source code. You can verify the md5sum.exe program against itself using the sumchecks below:

The file md5sum.exe is 48 Kb in size.


http://etree.org/cgi-bin/counter.cgi/software/md5sum.exe eb574b236133e60c989c6f472f07827b
http://theopencd.sunsite.dk/md5sum.exe eb574b236133e60c989c6f472f07827b
http://www.fourmilab.ch/md5/md5.zip b14e189e965e5ed523282d3c8ee6c945
http://downloads.activestate.com/contrib/md5sum/Windows/md5sum.exe eb574b236133e60c989c6f472f07827b


Then just open a command (console) window, navigate to where you have put the mushclient installer, and type something like this (depending on the version):


c:\> md5sum mushclient378.exe
a6db5e2a12b90344d30b9566a7fab19d *mushclient378.exe


The result is the same as before (the upper-case/lower-case difference is not relevant).