Both Base32 and Base64 check that the final bits from the trailing digit that will be discarded are zero.
The test for the trailing bits in the final digits in Base64 is:
It should be:
Likewise in Base32.
The following base64 is illegal but is still decoded:
Here the check for the 4 trailing bits to drop in this case checks only bit 3 and ignores bit 1 which is set.
Same for Base32, this is illegal:
But the check for the 2 trailing bits to drop in this case checks bit 2 and ignores bit 1 which is set.
Note: The test cases using "AC" has bit 2 set and so is flagged as invalid.