1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Scribunto: Add HashLibrary [#589]

This commit is contained in:
gnosygnu
2019-10-12 15:07:21 -04:00
parent 9f0cfc27bb
commit 866debd51d
58 changed files with 1610 additions and 253 deletions

View File

@@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
import gplx.core.progs.*;
import gplx.core.security.*; import gplx.core.security.files.*;
import gplx.core.security.algos.*; import gplx.core.security.files.*;
public class Xobc_cmd__verify_dir extends Xobc_cmd__base {
private final Io_url delete_fil, checksum_fil;
public Xobc_cmd__verify_dir(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_idx, Io_url checksum_fil, Io_url delete_fil) {super(task_mgr, task_id, step_id, cmd_idx);
@@ -41,7 +41,7 @@ public class Xobc_cmd__verify_dir extends Xobc_cmd__base {
gplx.core.ios.streams.IoStream stream = Io_mgr.Instance.OpenStreamRead(itm.File_url);
byte[] actl_hash = Bry_.Empty;
this.Prog_data_cur_(prog_data_cur);
try {actl_hash = algo.Hash_stream_as_bry(this, stream);}
try {actl_hash = Hash_algo_utl.Calc_hash_w_prog_as_bry(algo, stream, this);}
finally {stream.Rls();}
prog_data_cur += itm.File_size;
if (this.Prog_notify_and_chk_if_suspended(prog_data_cur, Prog_data_end())) return;

View File

@@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
import gplx.core.progs.*; import gplx.core.security.*;
import gplx.core.progs.*; import gplx.core.security.algos.*;
public class Xobc_cmd__verify_fil extends Xobc_cmd__base {
private final Io_url src_url; private final byte[] expd_hash;
public Xobc_cmd__verify_fil(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_id, Io_url src_url, String expd_hash_str, long prog_data_end) {super(task_mgr, task_id, step_id, cmd_id);
@@ -30,7 +30,7 @@ public class Xobc_cmd__verify_fil extends Xobc_cmd__base {
Hash_algo algo = Hash_algo_.New__md5();
gplx.core.ios.streams.IoStream stream = Io_mgr.Instance.OpenStreamRead(src_url);
byte[] actl_hash = Bry_.Empty;
try {actl_hash = algo.Hash_stream_as_bry(this, stream);}
try {actl_hash = Hash_algo_utl.Calc_hash_w_prog_as_bry(algo, stream, this);}
finally {stream.Rls();}
if (this.Prog_status() != Gfo_prog_ui_.Status__suspended && !Bry_.Eq(expd_hash, actl_hash))
this.Cmd_exec_err_(Xobc_cmd__verify_fil.Err_make(actl_hash, expd_hash));

View File

@@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.*;
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.algos.*;
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.fsdb.*; import gplx.fsdb.meta.*;
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.hosts.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
public class Pack_file_mgr {
@@ -138,7 +138,7 @@ public class Pack_file_mgr {
Io_url raw_url = raw_urls[i];
IoStream raw_stream = Io_mgr.Instance.OpenStreamRead(raw_url);
byte[] raw_md5 = null;
try {raw_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, raw_stream);}
try {raw_md5 = Hash_algo_utl.Calc_hash_w_prog_as_bry(hash_algo, raw_stream, Gfo_prog_ui_.Noop);}
finally {raw_stream.Rls();}
tmp_bfr.Add(raw_md5).Add_byte_space().Add_byte(Byte_ascii.Star).Add_str_a7(raw_url.NameAndExt()).Add_byte_nl();
raw_size += raw_stream.Len();
@@ -156,7 +156,7 @@ public class Pack_file_mgr {
Gfo_log_.Instance.Prog("hashing zip");
IoStream zip_stream = Io_mgr.Instance.OpenStreamRead(zip_url);
byte[] zip_md5 = null;
try {zip_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, zip_stream);}
try {zip_md5 = Hash_algo_utl.Calc_hash_w_prog_as_bry(hash_algo, zip_stream, Gfo_prog_ui_.Noop);}
finally {zip_stream.Rls();}
long zip_len = Io_mgr.Instance.QueryFil(zip_url).Size();

View File

@@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.exports.packs.splits; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.*;
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.algos.*;
import gplx.dbs.*;
import gplx.xowa.wikis.data.*;
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*;
@@ -97,7 +97,7 @@ class Pack_mgr {
Io_url raw_url = raw_urls[i];
IoStream raw_stream = Io_mgr.Instance.OpenStreamRead(raw_url);
byte[] raw_md5 = null;
try {raw_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, raw_stream);}
try {raw_md5 = Hash_algo_utl.Calc_hash_w_prog_as_bry(hash_algo, raw_stream, Gfo_prog_ui_.Noop);}
finally {raw_stream.Rls();}
tmp_bfr.Add(raw_md5).Add_byte_space().Add_byte(Byte_ascii.Star).Add_str_a7(raw_url.NameAndExt()).Add_byte_nl();
raw_size += raw_stream.Len();
@@ -126,7 +126,7 @@ class Pack_mgr {
Gfo_log_.Instance.Prog("hashing zip");
IoStream zip_stream = Io_mgr.Instance.OpenStreamRead(zip_url);
byte[] zip_md5 = null;
try {zip_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, zip_stream);}
try {zip_md5 = Hash_algo_utl.Calc_hash_w_prog_as_bry(hash_algo, zip_stream, Gfo_prog_ui_.Noop);}
finally {zip_stream.Rls();}
long zip_len = Io_mgr.Instance.QueryFil(zip_url).Size();

View File

@@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.files.cksums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
import gplx.core.ios.streams.*; import gplx.core.security.*;
import gplx.core.ios.streams.*; import gplx.core.security.algos.*;
import gplx.dbs.*; import gplx.xowa.addons.bldrs.files.cksums.dbs.*;
import gplx.xowa.files.*; import gplx.fsdb.*; import gplx.fsdb.data.*;
public class Xocksum_calc_mgr {
@@ -49,7 +49,7 @@ public class Xocksum_calc_mgr {
bin_bry = Bry_.Empty;
}
row.Bin_size_(bin_bry.length);
byte[] md5 = md5_algo.Hash_bry_as_bry(bin_bry);
byte[] md5 = Hash_algo_utl.Calc_hash_as_bry(md5_algo, bin_bry);
if (!Bry_.Eq(md5, row.Cksum_val())) {
row.Cksum_val_(md5);
updates.Add(row);