mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -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,6 +6,7 @@
|
|||
|
||||
import Operation from "../Operation";
|
||||
import Utils from "../Utils";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
|
||||
/**
|
||||
|
@ -66,10 +67,10 @@ class DESDecrypt extends Operation {
|
|||
[,, mode, inputType, outputType] = args;
|
||||
|
||||
if (key.length !== 8) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||
|
||||
DES uses a key length of 8 bytes (64 bits).
|
||||
Triple DES uses a key length of 24 bytes (192 bits).`;
|
||||
Triple DES uses a key length of 24 bytes (192 bits).`);
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
@ -82,7 +83,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`;
|
|||
if (result) {
|
||||
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
|
||||
} else {
|
||||
return "Unable to decrypt input with these parameters.";
|
||||
throw new OperationError("Unable to decrypt input with these parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue