ESM: Ported all Hash and Checksum operations

This commit is contained in:
n1474335 2018-05-17 15:11:34 +00:00
parent 5362508a99
commit 3fd1f4e6d9
43 changed files with 1971 additions and 9 deletions

View file

@ -0,0 +1,54 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation";
import {runHash} from "../lib/Hash";
/**
* Snefru operation
*/
class Snefru extends Operation {
/**
* Snefru constructor
*/
constructor() {
super();
this.name = "Snefru";
this.module = "Hashing";
this.description = "Snefru is a cryptographic hash function invented by Ralph Merkle in 1990 while working at Xerox PARC. The function supports 128-bit and 256-bit output. It was named after the Egyptian Pharaoh Sneferu, continuing the tradition of the Khufu and Khafre block ciphers.<br><br>The original design of Snefru was shown to be insecure by Eli Biham and Adi Shamir who were able to use differential cryptanalysis to find hash collisions. The design was then modified by increasing the number of iterations of the main pass of the algorithm from two to eight.";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
"name": "Rounds",
"type": "option",
"value": ["8", "4", "2"]
},
{
"name": "Size",
"type": "option",
"value": ["256", "128"]
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return runHash("snefru", input, {
rounds: args[0],
length: args[1]
});
}
}
export default Snefru;