SHA256 in a Clipboard command

Opus has SHA256 hash support in its extended scripting API (in FSUtil.Hash), but it doesn't seem there is support for it in the Clipboard COPYNAMES=hash* (goes up to hash6 which is still SHA-1) -- so to use it one would have to use the full scripting instead of just a command?

So, can this be added to Clipboard COPYNAMES=hash* too?

SHA256 hashes are so long that we didn't think many people would want to do things with them manually. I think they were added as part of a request for a script that verifies hashes.

What kind of thing are you doing? Would it make sense as a script anyway?

It's easy to calculate the hashes in a script:

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	var fsu = DOpus.FSUtil;
	for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
	{
		var item = eSel.item();
		if (item.is_dir)
			continue;
		var hash = fsu.Hash(item.realpath, "sha256");
		DOpus.Output(item.name + ": " + hash);
	}
}

(If you want nice progress dialogs and error message, that makes it a bit harder, of course.)

Scripts can also set the clipboard via an object we provide, but presumably the data in the clipboard is going to be used somewhere; could the script send it straight to where it needs to be, bypassing the clipboard and automating things further?

1 Like

Thanks Leo, I actually just wanted SHA256 for Ubuntu ISO file verification (installation weirdly failed, so I tested my ISO with online SHA256 checker and it indeed was a corrupted download).

I might expand this into an add-in with drag & drop support and selectable hash functions etc. (but I vaguely remember somebody already made something like that here, will have to try to find it beforehand).

This is probably the script you're thinking of:

1 Like