Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OperationError when strict mode is enabled and text is not padded #1655

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pandaninjas
Copy link
Contributor

When Base64 input is not padded and strict mode is enabled, CyberChef rejects the input with the error "Error: Base64 input contains non-alphabet char(s)". This is because enc3 and enc4 might be -1 because the text doesn't have chars at the third and fourth locations

@CLAassistant
Copy link

CLAassistant commented Nov 20, 2023

CLA assistant check
All committers have signed the CLA.

@a3957273
Copy link
Member

Hey @pandaninjas, it feels like when enabling strict mode I'd expect things to fail if the Base64 isn't padded correctly. Is there a reason you think it shouldn't? The default behaviour does pass Base64 without proper padding correctly.

@pandaninjas
Copy link
Contributor Author

pandaninjas commented Feb 14, 2024

Hey @pandaninjas, it feels like when enabling strict mode I'd expect things to fail if the Base64 isn't padded correctly. Is there a reason you think it shouldn't? The default behaviour does pass Base64 without proper padding correctly.

It's not that it isn't padded correctly. If a Base64 alphabet does not have a padding character (i.e. the alphabet is 64 characters only), then decoding will always fail when padding is missing. See screenshot:
image

@pandaninjas
Copy link
Contributor Author

Though now that I think about it there's probably a better way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants