From e8dbc935d82dba4a01730506de88415dce6940ec Mon Sep 17 00:00:00 2001 From: zhangli091011 Date: Sun, 19 Jul 2026 09:41:57 +0800 Subject: [PATCH] Add pass-through to ROT13 brute force --- AI_MARKER | 1 + src/core/operations/ROT13BruteForce.mjs | 2 +- tests/operations/tests/Rotate.mjs | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 AI_MARKER diff --git a/AI_MARKER b/AI_MARKER new file mode 100644 index 00000000..cde79487 --- /dev/null +++ b/AI_MARKER @@ -0,0 +1 @@ +This contribution was prepared with AI assistance from OpenCode. diff --git a/src/core/operations/ROT13BruteForce.mjs b/src/core/operations/ROT13BruteForce.mjs index 7468ee11..bbbff1d0 100644 --- a/src/core/operations/ROT13BruteForce.mjs +++ b/src/core/operations/ROT13BruteForce.mjs @@ -73,7 +73,7 @@ class ROT13BruteForce extends Operation { const cribLower = crib.toLowerCase(); const lowerStart = "a".charCodeAt(0), upperStart = "A".charCodeAt(0), numStart = "0".charCodeAt(0); const result = []; - for (let amount = 1; amount < 26; amount++) { + for (let amount = 0; amount < 26; amount++) { const rotated = sample.slice(); for (let i = 0; i < rotated.length; i++) { if (rotateLower && lowerStart <= rotated[i] && rotated[i] < lowerStart + 26) { diff --git a/tests/operations/tests/Rotate.mjs b/tests/operations/tests/Rotate.mjs index a69e20fd..f243cbd3 100644 --- a/tests/operations/tests/Rotate.mjs +++ b/tests/operations/tests/Rotate.mjs @@ -256,6 +256,28 @@ TestRegister.addTests([ }, ], }, + { + name: "ROT13 Brute Force: includes pass-through", + input: "Abc123", + expectedMatch: /^Amount = {2}0: Abc123\nAmount = {2}1:/, + recipeConfig: [ + { + op: "ROT13 Brute Force", + args: [true, true, true, 100, 0, true, ""] + }, + ], + }, + { + name: "ROT13 Brute Force: filters a pass-through sample", + input: "__Ab1__", + expectedOutput: "Ab1", + recipeConfig: [ + { + op: "ROT13 Brute Force", + args: [true, true, true, 3, 2, false, "ab1"] + }, + ], + }, { name: "ROT47: nothing", input: "",