Skip to content

fix: make base32 decode case-insensitive#50

Merged
seetadev merged 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-36-base32-case-insensitive
Jul 13, 2026
Merged

fix: make base32 decode case-insensitive#50
seetadev merged 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-36-base32-case-insensitive

Conversation

@sumanjeet0012

Copy link
Copy Markdown
Contributor

Fixes #36

Description

This pull request makes Base32StringConverter case-insensitive during decoding, which complies with the multibase specification and matches the behavior of the Go reference implementation (go-multibase).

Previously, decoding a Base32 payload with mismatched case compared to its prefix encoding (e.g. base32 with an uppercase payload bMZXW6, or base32upper with a lowercase payload Bmzxw6) would raise a ValueError during alphabet mapping.

Changes Made

  • Modified Base32StringConverter.decode in multibase/converters.py to check self.digits.islower() and self.digits.isupper(). It now normalizes the payload's case to match the alphabet before iterating over the bytes.
  • Added explicit unit tests (test_decode_base32_case_insensitive) to tests/test_multibase.py to verify this behavior for base32, base32upper, base32pad, and base32hex.

Verification

  • Confirmed the newly added tests successfully pass (pytest tests/).
  • Verified all other pre-existing 266 tests pass.
  • Ensured make lint catches no errors and runs completely successfully.

@seetadev seetadev merged commit 1607cec into multiformats:master Jul 13, 2026
21 checks passed
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.

Base32 decode is case-sensitive — should be case-insensitive

2 participants