Sign in to follow this  
Followers 0
smasher953

Checksums?

3 posts in this topic

Has anyone used AutoIT to do any md5 or crc ro any other type of checksum checking? We have a few files that one of our AutoIT scripts will be downloading (rather large files) and we want to use md5sum or something to check it's checksum, and if it passes then continue with the script. If it doesn't pass, then give an error message. Has anyone else done anything like this? Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe try this command-line checksum util.

Idea code (not tested):

FileInstall(...) the md5sum.exe program into your compiled AutoItScript and then set working directory as needed....

run the program piping the output to a file which you then read:

Run(@ComSpec & " /c md5sum.exe fileToCheck.txt > sum.dat")
$sum = FileReadLine ("sum.dat)
$cut = StringInStr($sum, " ")
$sum = StringLeft($sum, $cut)

If $sum <> "ff7d3427330567857cf3dbc93abc43d7" Then
   MsgBox(4096,"","Checksum failed!")
EndIf

Hope that helps

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

I'm doing something similar with an md5sum variant. Here are the conditions you need to set up:

Assume a file named MyPic.tif:

Run md5sum MyPic.tif > MyPic.tif.md5

This creates MyPic.tif.md5 which contains the md5 hash for MyPic.tif paired with the filename MyPic.tif. You might need to hand edit the filename in MyPic.tif.md5 to remove the path information in front of the filename.

Run md5sum -c MyPic.tif.md5

This hashes the file named in MyPic.tif.md5 and compares the hash against the hash stored in MyPic.tif.md5. If run from a command prompt the return value is stored in %ErrorLevel%. If run using RunWait() in AutoIt the return value from md5hash is returned by RunWait() and will tell you whether or not the hashes match.

Different versions of md5sum vary a bit but all of them should work using the correct switches.

john

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0