mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Initial Commit – Working hash functionality
This commit is contained in:
parent
4fb4764d3f
commit
7d16265c4e
7 changed files with 189 additions and 0 deletions
48
src/core/operations/BLAKE2b.mjs
Normal file
48
src/core/operations/BLAKE2b.mjs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @author h [h]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import blakejs from "blakejs";
|
||||
|
||||
/**
|
||||
* BLAKE2b operation
|
||||
*/
|
||||
class BLAKE2b extends Operation {
|
||||
|
||||
/**
|
||||
* BLAKE2b constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "BLAKE2b";
|
||||
this.module = "Hashing";
|
||||
this.description = "Performs BLAKE2b hashing on the input. Returns the output HEX encoded.";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Size",
|
||||
"type": "option",
|
||||
"value": ["512", "384", "256", "160", "128"]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string} The input having been hashed with BLAKE2b, HEX encoded.
|
||||
*/
|
||||
run(input, args) {
|
||||
const [outSize] = args;
|
||||
return blakejs.blake2bHex(input, null, outSize / 8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default BLAKE2b;
|
48
src/core/operations/BLAKE2s.mjs
Normal file
48
src/core/operations/BLAKE2s.mjs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @author h [h]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import blakejs from "blakejs";
|
||||
|
||||
/**
|
||||
* BLAKE2s Operation
|
||||
*/
|
||||
class BLAKE2s extends Operation {
|
||||
|
||||
/**
|
||||
* BLAKE2s constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "BLAKE2s";
|
||||
this.module = "Hashing";
|
||||
this.description = "Performs BLAKE2s hashing on the input. Returns the output HEX encoded.";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Size",
|
||||
"type": "option",
|
||||
"value": ["256", "160", "128"]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string} The input having been hashed with BLAKE2s, HEX encoded.
|
||||
*/
|
||||
run(input, args) {
|
||||
const [outSize] = args;
|
||||
return blakejs.blake2sHex(input, null, outSize / 8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default BLAKE2s;
|
Loading…
Add table
Add a link
Reference in a new issue