Skip to content

Conversation

@rzuckerm
Copy link
Collaborator

Congrats on taking the first step to contributing to the Sample Programs repository maintained by The Renegade Coder!
For simplicity, please make sure that your pull request includes one and only one contribution.

Please fill one of the sections below as applicable.
Please also add any other relevant information to the Notes section at the bottom.
You may delete or just ignore any other sections.
For more information please refer to our contributing documentation

I Am Modifying an Existing Code Snippet or Existing Tests

  • I fixed Modify Base64 Encode Decode in Python #4587
  • I did not include any extra folders/libraries
  • I have read about modifying existing code snippets or tests in the contributing documentation
  • I have explained why this modification is necessary either in the issue linked above or in the notes below
  • I named the pull request using Modify {PROJECT} {tests} in {LANGUAGE} format

Other Notes

Although this sample currently works, if you run this, you will get this error:

>>> import base64
>>> base64.b64decode(b"hello world=")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

What this implies is that the invalid Base64 character (' ') is being ignored. However, if you run this, you will get the proper error:

>>> base64.b64decode(b"hello world=", validate=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/base64.py", line 86, in b64decode
    raise binascii.Error('Non-base64 digit found')
binascii.Error: Non-base64 digit found

This is the correct error.

@rzuckerm rzuckerm added enhancement Any code that improves the repo base64 encode decode See: https://sampleprograms.io/projects/base64-encode-decode/ labels Mar 31, 2025
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@rzuckerm rzuckerm marked this pull request as ready for review March 31, 2025 22:12
@rzuckerm rzuckerm enabled auto-merge (squash) March 31, 2025 22:12
@rzuckerm rzuckerm merged commit 1231148 into TheRenegadeCoder:main Apr 1, 2025
7 checks passed
@rzuckerm rzuckerm deleted the modify-python-base64 branch April 1, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

base64 encode decode See: https://sampleprograms.io/projects/base64-encode-decode/ enhancement Any code that improves the repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modify Base64 Encode Decode in Python

2 participants