mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
ESM: Ported all Hash and Checksum operations
This commit is contained in:
parent
5362508a99
commit
3fd1f4e6d9
43 changed files with 1971 additions and 9 deletions
54
src/core/operations/Bcrypt.mjs
Normal file
54
src/core/operations/Bcrypt.mjs
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
/**
|
||||
* Bcrypt operation
|
||||
*/
|
||||
class Bcrypt extends Operation {
|
||||
|
||||
/**
|
||||
* Bcrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Bcrypt";
|
||||
this.module = "Hashing";
|
||||
this.description = "bcrypt is a password hashing function designed by Niels Provos and David Mazi\xe8res, based on the Blowfish cipher, and presented at USENIX in 1999. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count (rounds) can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power.<br><br>Enter the password in the input to generate its hash.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Rounds",
|
||||
"type": "number",
|
||||
"value": 10
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async run(input, args) {
|
||||
const rounds = args[0];
|
||||
const salt = await bcrypt.genSalt(rounds);
|
||||
|
||||
return await bcrypt.hash(input, salt, null, p => {
|
||||
// Progress callback
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage(`Progress: ${(p * 100).toFixed(0)}%`);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Bcrypt;
|
Loading…
Add table
Add a link
Reference in a new issue