mirror of
https://github.com/gchq/CyberChef
synced 2025-12-20 10:13:42 +00:00
Converted substitute operation, added tests & moved to OperationError
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
|
||||
/**
|
||||
* Vigenère Encode operation
|
||||
@@ -45,8 +46,8 @@ class VigenèreEncode extends Operation {
|
||||
msgIndex,
|
||||
chr;
|
||||
|
||||
if (!key) return "No key entered";
|
||||
if (!/^[a-zA-Z]+$/.test(key)) return "The key must consist only of letters";
|
||||
if (!key) throw new OperationError("No key entered");
|
||||
if (!/^[a-zA-Z]+$/.test(key)) throw new OperationError("The key must consist only of letters");
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
if (alphabet.indexOf(input[i]) >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user