Fixes #2079: Update "From Base32" operation to support strict mode and custom padding#2082
Open
irebased wants to merge 5 commits intogchq:masterfrom
Open
Fixes #2079: Update "From Base32" operation to support strict mode and custom padding#2082irebased wants to merge 5 commits intogchq:masterfrom
irebased wants to merge 5 commits intogchq:masterfrom
Conversation
…o 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.
…o 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.
Author
|
Checking in on this since it has been some time. How frequently does this repository have PRs merged? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This implements #2079
The From Base64 operation allows for a strict mode, and also allows removing the padding character from the alphabet. The From Base32 operation, on the other hand, is not aligned with this design and produces an "Invalid byte array".
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 a valid output, even without a padding character.
This change also enables users to provide custom padding characters instead of forcing
=.Example:
Existing result:
Result after this change:
How it works
nullinstead of=to allow for the absence of a padding character=-1and causing an invalid byte array5n + 1in length as it is an invalid length for a Base32 string.Testing
All unit tests for Base32 continue to pass after this change. I also tested the following inputs and got valid results:
References
See the Base64 implementation.