mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Converted substitute operation, added tests & moved to OperationError
This commit is contained in:
parent
350d10d98b
commit
2d6a56343b
8 changed files with 125 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
import Operation from "../Operation";
|
||||
import Utils from "../Utils";
|
||||
import OperationError from "../errors/OperationError";
|
||||
|
||||
/**
|
||||
* Affine Cipher Decode operation
|
||||
|
@ -50,11 +51,11 @@ class AffineCipherDecode extends Operation {
|
|||
let output = "";
|
||||
|
||||
if (!/^\+?(0|[1-9]\d*)$/.test(a) || !/^\+?(0|[1-9]\d*)$/.test(b)) {
|
||||
return "The values of a and b can only be integers.";
|
||||
throw new OperationError("The values of a and b can only be integers.");
|
||||
}
|
||||
|
||||
if (Utils.gcd(a, 26) !== 1) {
|
||||
return "The value of `a` must be coprime to 26.";
|
||||
throw new OperationError("The value of `a` must be coprime to 26.");
|
||||
}
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue