Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ A small script to sumcheck the MUSHclient download

A small script to sumcheck the MUSHclient download

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Sat 19 Aug 2006 04:42 AM (UTC)

Amended on Sat 19 Aug 2006 04:44 AM (UTC) by Nick Gammon

Message
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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 19 Aug 2006 04:48 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 19 Aug 2006 04:51 AM (UTC)

Amended on Fri 30 Jul 2010 03:22 AM (UTC) by Nick Gammon

Message
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 between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Installer_sumcheck.xml
  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"



<?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>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 19 Aug 2006 05:02 AM (UTC)
Message
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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 19 Aug 2006 05:08 AM (UTC)

Amended on Sat 19 Aug 2006 05:38 AM (UTC) by Nick Gammon

Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


25,327 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.