This commit is contained in:
john19696 2022-09-22 16:53:29 +01:00
parent 00f0101723
commit be97a0062e

View File

@ -94,14 +94,14 @@ class GenerateAllHashes extends Operation {
{"name": "Whirlpool-0", "hash": (new Whirlpool()), "type": "arrayBuffer", params: ["Whirlpool-0"]},
{"name": "Whirlpool-T", "hash": (new Whirlpool()), "type": "arrayBuffer", params: ["Whirlpool-T"]},
{"name": "Whirlpool", "hash": (new Whirlpool()), "type": "arrayBuffer", params: ["Whirlpool"]},
{"name": "BLAKE2b-128", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["128","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-160", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["160","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-256", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["256","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-384", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["384","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-512", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["512","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-128", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["128","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-160", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["160","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-256", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["256","Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-128", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["128", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-160", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["160", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-256", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["256", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-384", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["384", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2b-512", "hash": (new BLAKE2b), "type": "arrayBuffer", params: ["512", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-128", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["128", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-160", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["160", "Hex", {string: "", option: "UTF8"}]},
{"name": "BLAKE2s-256", "hash": (new BLAKE2s), "type": "arrayBuffer", params: ["256", "Hex", {string: "", option: "UTF8"}]},
{"name": "Streebog-256", "hash": (new Streebog), "type": "arrayBuffer", params: ["256"]},
{"name": "Streebog-512", "hash": (new Streebog), "type": "arrayBuffer", params: ["512"]},
{"name": "GOST", "hash": (new GOSTHash), "type": "arrayBuffer", params: ["D-A"]},
@ -133,13 +133,13 @@ class GenerateAllHashes extends Operation {
str = Utils.arrayBufferToStr(arrayBuffer, false),
byteArray = new Uint8Array(arrayBuffer);
var value, output = "";
let value, output = "";
// iterate over each of the hashes
this.hashes.forEach(function (hash) {
// calculate the hash value
if (hash.type == "arrayBuffer") {
if (hash.type === "arrayBuffer") {
value = hash.hash.run(arrayBuffer, hash.params);
} else if (hash.type == "str") {
} else if (hash.type === "str") {
if ("params" in hash) {
value = hash.hash.run(str, hash.params);
} else {
@ -147,7 +147,7 @@ class GenerateAllHashes extends Operation {
}
}
// output the values base on the args: length & names
if (length == "All" || value.length === parseInt(length)) {
if (length === "All" || value.length === parseInt(length)) {
if (names) {
output += hash.name + ":" + " ".repeat(13-hash.name.length);
}
@ -155,7 +155,7 @@ class GenerateAllHashes extends Operation {
}
});
if (length == "All") {
if (length === "All") {
output += "\nChecksums:" +
"\nFletcher-8: " + (new Fletcher8Checksum).run(byteArray, []) +
"\nFletcher-16: " + (new Fletcher16Checksum).run(byteArray, []) +