GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Column: SHA-256

Overview

This simple script adds an SHA-256 hash/checksum column, similar to the built-in columns for MD5 and SHA-1.

Unlike the built-in columns, there is no maximum size limit, but you could add one if you wanted to.

Installing

  • Requires Opus 12.17.1 or above.
  • Download SHA-256.js.txt (903 Bytes)
  • Drag it to the list under Preferences / Toolbars / Scripts.
  • You can then find the column under the Scripts category.

History

  • v1.1 (01/Oct/2019):
    • Fix for Opus giving up waiting on calculation of large/slow files.
    • Requires Opus 12.17.1 beta or later, for the new timeout property.
  • v1.0 (15/Sep/2019):
    • Initial release.

Script code

The contents of the .js.txt file above are reproduced here so you can see how it works without downloading it:

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "SHA-256";
	initData.version = "1.1";
	initData.copyright = "(c) 2019 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/column-sha-256/33525";
	initData.desc = "SHA-256 hash column";
	initData.default_enable = true;
	initData.min_version = "12.17.1";

	var col = initData.AddColumn();
	col.name = "SHA256";
	col.method = "OnSHA256";
	col.label = "SHA256";
	col.justify = "left";
	col.autogroup = true;
	// Tell Opus to Wait for us forever without giving up.
	// Hashing large files can take a long time.
	col.timeout = 0;
}

// Implement the SHA256 column
function OnSHA256(scriptColData)
{
	if (scriptColData.col == "SHA256"
	&&  !scriptColData.item.is_dir)
	{
		scriptColData.value = DOpus.FSUtil().Hash(
			scriptColData.item.realpath,
			"sha256");
	}
}
1 Like

Root post updated with v1.1:

  • Fix for Opus giving up waiting on calculation of large/slow files.
  • Requires Opus 12.17.1 beta or later, for the new timeout property.