mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-15 10:44:50 -04:00
Wrapped XOR run function in try catch block to handle key errors
This commit is contained in:
parent
7c8be12d52
commit
01edeb28a6
1 changed files with 9 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import Utils from "../Utils.mjs";
|
import Utils from "../Utils.mjs";
|
||||||
import { bitOp, xor, BITWISE_OP_DELIMS } from "../lib/BitwiseOp.mjs";
|
import { bitOp, xor, BITWISE_OP_DELIMS } from "../lib/BitwiseOp.mjs";
|
||||||
|
|
||||||
|
@ -51,11 +52,15 @@ class XOR extends Operation {
|
||||||
* @returns {byteArray}
|
* @returns {byteArray}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
|
try {
|
||||||
input = new Uint8Array(input);
|
input = new Uint8Array(input);
|
||||||
const key = Utils.convertToByteArray(args[0].string || "", args[0].option),
|
const key = Utils.convertToByteArray(args[0].string || "", args[0].option),
|
||||||
[, scheme, nullPreserving] = args;
|
[, scheme, nullPreserving] = args;
|
||||||
|
|
||||||
return bitOp(input, key, xor, nullPreserving, scheme);
|
return bitOp(input, key, xor, nullPreserving, scheme);
|
||||||
|
} catch (error) {
|
||||||
|
throw new OperationError("Invalid Characters in key");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue