Note: This script now requires a minimum Opus version 11.16…
This script was written in response to a request from TheSeeker in the following discussion:
What does it do?:
This script adds a ‘HashCompare’ Script Command to Opus. Such commands can be used like any other Opus internal commands directly in toolbar buttons, hotkeys, etc. The ‘HashCompare’ command is intended by default to help you easily validate a hash / checksum provided by the website (or other trusted reference) you’ve downloaded a file from against the actual checksum of the file as calculated by Opus. The command expects you to have already copied the trusted checksum to your clipboard (for example, copied to the clipboard from your web browser) before then selecting your downloaded copy of the file in an Opus lister and then running the ‘HashCompare’ command. The script provides various popup dialogs to let you know what’s happening…
In response to a user request (and my own needs ), the script was updated to allow a FILE option which compares the hashes of two selected files, instead of just one against the clipboard.
The command currently supports only two options that control which type of hash value the script will generate for comparison. Those options are MD5 or SHA… and will default to MD5 if no option is specified. If GPSoft ever add support for additional hash types to Opus (say SHA-512), updating the script to support them will be trivial.
How to install and use it?:
The script is provided here as an Opus Script Package… which in turn is actually a zip file with a VBScript packaged inside. It can be installed by either manually copying the OSP file to the /dopusdata\Script AddIns folder, or via drag-and-drop into the Preferences / Toolbars / Scripts page.
Download: HashCompare.osp (3.92 KB)
2014-09-11: Initial release…
2014-09-12: v1.1.0 - This update moves the point at which the clipboard content gets reset back to it’s original state due to some misbehavior in the original version. Some of the popup messages were also tweaked
[ul][li] Added an ‘info’ icon to successful comparison popup to provide a more obvious visual indicator of success[/li]
[li] A progress dialog is now provided while Opus is calculating the hash value[/li]
[li] The ‘Ok’ button has been turned into a drop-down menu button with an option to copy the newly calculated hash value to the clipboard (otherwise, the clipboard is returned to it’s original state)[/li][/ul]2015-12-31: v1.2.1 - Renamed script, and added a FILE option to compare two selected file checksums instead of 1 selected file against the clipboard, added a DEBUG_CLEAR config option, added config option descriptions, made several messaging changes, set minimum Opus version to v11.16
2016-01-28: v1.2.5 - Added support for comparing two files from different tabs (in the same or different lister), since I very often have files who’s hashes I want to compare in different folders and even different drives; and moving them to the same folder the way the first use of the FILE option worked isn’t always practical. Also added a TOFILE option to write the calculated hash value out to a file named .. So the MD5 hash for foo.bin will be written to foo.bin.MD5. If multiple files are selected, then each file gets it’s own hash file.
2016-11-22: v1.2.7 - A minor cleanliness update with fixes for the problems DesertDwarf noticed re: DOpus.SetClip.
After installing the script package, users can configure the scripts options via the scripts listing in Prefs (Configure button):
There are only debug logging options in the current version of this script:
Once installed, you can then use the HashCompare command just like any other Opus command:
How does it work?:
The HashCompare script command operates against selected items and the clipboard. It does not take explicit file name/path arguments, but otherwise supports several other command line options:
[ul][li]CLIP Compares the hash of a single selected file (only first if multiple are selected) against the clipboard contents. Intended for comparing the actual hash of a file from against the hash posted for it on the website from which you downloaded it… This is the default behavior if not otherwise specified on the command line.[/li]
[li]FILE Compares the hash values of the 2 files (only the first two if multiple are selected) against each other. Currently, the two files need to be in the same folder/file display.[/li]
[li]MD5 Performs an MD5 based hash comparison. This is the default behavior if not otherwise specified on the command line.[/li]
[li]SHA Performs an SHA based hash comparison.[/li][/ul]
For comparisons of a SINGLE files hash against the Clipboard:
The script shows a progress dialog while the hash is being calculated for the file:
For a successful comparison:
For a failed comparison:
In the event that things required for the script to do it’s job are missing, the script will throw various obvious errors:
For comparisons of TWO files hashes against each other:
The script shows a separate progress dialog for each file while the hash is being calculated for the files:
Note that due to both my poor understanding of how to use the Progress dialog object that Opus provides, as well as perhaps some limitations in using it the way I’d like to - when using the FILE option to compare two files as is shown here, the percentage indicator in the progress dialogs title will NOT show numeric progress percentage as each files hash is being calculated like you get with the dialog for a single files comparison against the clipboard (above). It will only show 0% as the first file begins, 50% as the second file begins, and then briefly flash 100% upon the second files completion. HOWEVER, the top progress meter (BAR) does in fact at least accurately show relative progress of each individual file.
Note: As of v1.2.5 I’ve made changes to my original use of the progress dialog. I found that Opus would not run a single ‘Clipboard COPYNAMES’ command with two files from different folders added to the scripting object used to run the command. This meant I had to run two separate commands, and that caused me to lose the ‘All files’ overall progress of the full progress dialog all-together. So it’s no longer a full progress dialog anymore, but you’ll still see the percentage progress for each file separately.
For a successful comparison:
For a failed comparison:
Again, in the event that things required for the script to do it’s job are missing, the script will throw various obvious errors:
Feedback appreciated… I may make additional changes to allow the new FILE option to compare files from different folders… as having them in the same folder is sometimes a PITA.