CyberChef icon indicating copy to clipboard operation
CyberChef copied to clipboard

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

Open pandaninjas opened this issue 1 year ago • 4 comments

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

pandaninjas avatar Nov 20 '23 18:11 pandaninjas

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 20 '23 18:11 CLAassistant

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.

a3957273 avatar Feb 13 '24 01:02 a3957273

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 avatar Feb 14 '24 03:02 pandaninjas

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

pandaninjas avatar Feb 14 '24 03:02 pandaninjas