The current script looks like this:
function OnInit(initData)
{
initData.name = "save_HASHs_to_file";
initData.version = "1.0";
initData.copyright = "(c) 2021 t23111";
initData.url = "";
initData.desc = "Save file HASH summ to text file.";
initData.default_enable = true;
initData.min_version = "";
var cmd = initData.AddCommand();
cmd.name = "save_HASHs_to_file";
cmd.method = "save_HASHs_to_file";
//cmd.desc = "Save file HASH summ to text file.";
//cmd.label = "save_HASHs_to_file";
//cmd.template = "FILE,ADD/S,REMOVE/S,TOGGLE/S";
//cmd.hide = false;
//cmd.icon = "edit";
}
function save_HASHs_to_file(clickData)
{
if (clickData.func.sourcetab.selected.count == 0)
{
var dlg= DOpus.Dlg;
dlg.message="Please select a file!";
dlg.Show;
return;
}
else
{
for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
{
if (eSel.item().is_dir)
{
var dlg= DOpus.Dlg;
dlg.message=eSel.item().RealPath +" is folder, not a file!";
dlg.Show;
}
else
{
//New File Name
var filepath = eSel.item().path + "\\";
var filename = eSel.item().name;
var filesize = eSel.item().size;
var filenamenew = eSel.item().name + "_HASHs.txt";
var filepathnew = filepath + filenamenew;
//File Data Modify, Create and Access
var date_create = DOpus.Create.Date(eSel.item().create);
var date_create_utc = DOpus.Create.Date(eSel.item().create_utc);
var date_modify = DOpus.Create.Date(eSel.item().modify);
var date_modify_utc = DOpus.Create.Date(eSel.item().modify_utc);
var date_access = DOpus.Create.Date(eSel.item().access);
var date_access_utc = DOpus.Create.Date(eSel.item().access_utc);
//File HASH summ
var crc32 = DOpus.FSUtil.Hash(eSel.item().RealPath,"crc32").toUpperCase();
var crc32_php = DOpus.FSUtil.Hash(eSel.item().RealPath,"crc32_php").toUpperCase();
var crc32_php_rev = DOpus.FSUtil.Hash(eSel.item().RealPath,"crc32_php_rev").toUpperCase();
var md5 = DOpus.FSUtil.Hash(eSel.item().RealPath,"md5").toUpperCase();
var sha1 = DOpus.FSUtil.Hash(eSel.item().RealPath,"sha1").toUpperCase();
var sha256 = DOpus.FSUtil.Hash(eSel.item().RealPath,"sha256").toUpperCase();//sha256 incorrect for large files >= 512 Mb :((
var sha512 = DOpus.FSUtil.Hash(eSel.item().RealPath,"sha512").toUpperCase();//sha256 incorrect for large files >= 512 Mb :((
//File Content
var filecontent =
"File Name: " + eSel.item().name
+ "\n" + "File Size: " + filesize.fmt + " (" + number_on_three(filesize) + " bytes)"
+ "\n\n" + "File Date Create: \t\t" + date_create.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n" + "File Date Create UTC: \t" + date_create_utc.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n" + "File Date Modify: \t\t" + date_modify.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n" + "File Date Modify UTC: \t" + date_modify_utc.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n" + "File Date Access: \t\t" + date_access.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n" + "File Date Access UTC: \t" + date_access_utc.Format("D#yyyy.MM.dd, T#HH:mm:ss")
+ "\n\n" + "CRC32 (7-Zip; PKZip; CRC32b in PHP): \n" + crc32
+ "\n" + "CRC32_PHP (BZIP2; CRC32 in PHP): \n" + crc32_php
+ "\n" + "CRC32_PHP_REV (CRC32 in PHP with byte-order reversed): \n" + crc32_php_rev
+ "\n" + "SHA-1: \n" + sha1
+ "\n" + "SHA-256: \n" + sha256
+ "\n" + "SHA-512: \n" + sha512;
var filecontentencode = DOpus.Create.StringTools.Encode(filecontent, "utf-8 bom");//Encode to UTF-8-BOM
var file = DOpus.FSUtil.OpenFile(filepathnew, "wa");//Create text File for write
if (file.error == 0)
{
file.Write(filecontentencode);//Write to file
file.Close();
}
var dlg= DOpus.Dlg;
dlg.message="File is complete!";
dlg.Show;
}
}
}
}
function number_on_three(x) {
return String(x).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
for the file "experienceindexok_x64_p.exe"
creates a text file
UTF-8-BOM encoded
with the name "ExperienceIndexOK_x64_p.exe_HASHs.txt"
with the following content:
File Name: ExperienceIndexOK_x64_p.exe
File Size: 132 Kb (135 560 bytes)
File Date Create: 2021.01.03, 16:09:23
File Date Create UTC: 2021.01.03, 13:09:23
File Date Modify: 2021.01.04, 20:22:59
File Date Modify UTC: 2021.01.04, 17:22:59
File Date Access: 2021.01.03, 16:09:23
File Date Access UTC: 2021.01.03, 13:09:23
CRC32 (7-Zip; PKZip; CRC32b in PHP):
85BCE596
CRC32_PHP (BZIP2; CRC32 in PHP):
5CD90305
CRC32_PHP_REV (CRC32 in PHP with byte-order reversed):
0503D95C
SHA-1:
A1A8C4DC6156FD47BABAE83311AAEF58B7CE3542
SHA-256:
C6AE6D4F2725EB11A9FC929FF1C5CACF50E9040B6EE2DBB2384072A41F2DB4E8
SHA-512:
8AD7D88B92612CD5EF1D09D751C941233EA55987227B92DDA795DDDF49596C7C6F619FA719D30148405103C76A6105531B8611706B5294353A344C5783184F87
QUESTION!!!
How do I make the calculation progress dialog graphical? (For example, in the form of a green bar.)