From 2c32a64bfed7698d5d4b3daf82c5de1fd8f928a3 Mon Sep 17 00:00:00 2001 From: Odyhibit Date: Fri, 21 Feb 2025 20:40:37 -0600 Subject: [PATCH] Remove trim from rail fence. --- src/core/operations/RailFenceCipherDecode.mjs | 2 +- src/core/operations/RailFenceCipherEncode.mjs | 2 +- tests/operations/tests/Ciphers.mjs | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/operations/RailFenceCipherDecode.mjs b/src/core/operations/RailFenceCipherDecode.mjs index be54ee12..39795f21 100644 --- a/src/core/operations/RailFenceCipherDecode.mjs +++ b/src/core/operations/RailFenceCipherDecode.mjs @@ -72,7 +72,7 @@ class RailFenceCipherDecode extends Operation { } } - return plaintext.join("").trim(); + return plaintext.join(""); } } diff --git a/src/core/operations/RailFenceCipherEncode.mjs b/src/core/operations/RailFenceCipherEncode.mjs index 03651f85..89eddde7 100644 --- a/src/core/operations/RailFenceCipherEncode.mjs +++ b/src/core/operations/RailFenceCipherEncode.mjs @@ -66,7 +66,7 @@ class RailFenceCipherEncode extends Operation { rows[rowIdx] += plaintext[pos]; } - return rows.join("").trim(); + return rows.join(""); } } diff --git a/tests/operations/tests/Ciphers.mjs b/tests/operations/tests/Ciphers.mjs index 47453cf7..16aba950 100644 --- a/tests/operations/tests/Ciphers.mjs +++ b/tests/operations/tests/Ciphers.mjs @@ -528,4 +528,15 @@ TestRegister.addTests([ } ], }, + { + name: "Rail Fence Cipher Encode: Normal with Offset with Spaces", + input: "No one expects the spanish Inquisition.", + expectedOutput: " e n ut.ooeepcstesaihIqiiinNnxthpsnso", + recipeConfig: [ + { + "op": "Rail Fence Cipher Encode", + "args": [3, 2] + } + ], + }, ]);