mirror of
https://github.com/gchq/CyberChef.git
synced 2025-07-19 02:56:02 -04:00
ESM: Tidied up recently ported ops
This commit is contained in:
parent
905bc6699e
commit
6768038a2f
14 changed files with 47 additions and 27 deletions
|
@ -6,12 +6,17 @@
|
|||
|
||||
import Operation from "../Operation";
|
||||
import Utils from "../Utils";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import { Blowfish } from "../vendor/Blowfish";
|
||||
import { toBase64 } from "../lib/Base64";
|
||||
|
||||
/**
|
||||
* Lookup table for Blowfish output types.
|
||||
*/
|
||||
const BLOWFISH_OUTPUT_TYPE_LOOKUP = {
|
||||
Base64: 0, Hex: 1, String: 2, Raw: 3
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup table for Blowfish modes.
|
||||
*/
|
||||
|
@ -77,7 +82,7 @@ class BlowfishEncrypt extends Operation {
|
|||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
[,, mode, inputType, outputType] = args;
|
||||
|
||||
if (key.length === 0) return "Enter a key";
|
||||
if (key.length === 0) throw new OperationError("Enter a key");
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
|
@ -88,7 +93,7 @@ class BlowfishEncrypt extends Operation {
|
|||
cipherMode: BLOWFISH_MODE_LOOKUP[mode]
|
||||
});
|
||||
|
||||
return outputType === "Raw" ? Utils.byteArrayToChars(enc) : enc ;
|
||||
return outputType === "Raw" ? Utils.byteArrayToChars(enc) : enc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue