From c2df52264634934f6b91daf9598daa5b5e1b5676 Mon Sep 17 00:00:00 2001 From: The Winter Soldier Date: Tue, 29 Jul 2025 00:08:52 -0700 Subject: [PATCH] Fixes #2079: Update Base32 operation to support strict mode and no padding The Base64 operation allows for a strict mode, and also allows for removing the padding character from the alphabet. Base32 on the other hand is not aligned with this design. This change updates the Base32 operation to include a strict mode which enforces the same rules as the Base64 tool (adhering to Base32 expectations instead of Base64, such as a maximum of 6 padding characters). In non-strict mode, this allows the user to enter inputs that are not divisible by 8 while still producing an output, such as inputting "GE" to get the output "1" with alphabet "A-Z2-7" (no padding characer). All unit tests for Base32 continue to pass after this change. --- src/core/lib/Base32.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/Base32.mjs b/src/core/lib/Base32.mjs index 002a51662..007b6b32a 100644 --- a/src/core/lib/Base32.mjs +++ b/src/core/lib/Base32.mjs @@ -61,7 +61,7 @@ export function fromBase32(data, alphabet="A-Z0-7=", returnType="string", remove if (strictMode) { // Check for incorrect lengths (even without padding) if (data.length % 8 === 1) { - throw new OperationError(`Error: Invalid Base32 input length (${data.length}). Cannot be 5n+1, even without padding chars.`); + throw new OperationError(`Error: Invalid Base32 input length (${data.length}). Cannot be 8n+1, even without padding chars.`); } if (alphabet.length === 33) { // Padding character included