Skip to content

Fix: Change default encoding of CIDv1 to base32#77

Open
sumanjeet0012 wants to merge 2 commits into
ipld:masterfrom
sumanjeet0012:fix-66-default-base32
Open

Fix: Change default encoding of CIDv1 to base32#77
sumanjeet0012 wants to merge 2 commits into
ipld:masterfrom
sumanjeet0012:fix-66-default-base32

Conversation

@sumanjeet0012

Copy link
Copy Markdown

Description

This PR addresses the issue where CIDv1.encode() incorrectly defaulted to base58btc. The CID specification officially recommends base32 as the default encoding for CIDv1 strings. This aligns py-cid with the spec and with other implementations such as Go's Cid.String().

Changes

  • Updated CIDv1.encode to use "base32" as the default encoding parameter.
  • Updated test_encode_default in tests/test_cid.py to assert against the base32 encoded string rather than base58btc.

Warning

Breaking Change: The default output of str(cid) and cid.encode() for all CIDv1 objects will now be base32 strings (which begin with b) instead of base58btc strings (which begin with z). Ensure you document this in the release notes so downstreams relying on default base58btc serialization can update their code to explicitly pass cid.encode("base58btc") if they rely on the older behavior.

@sumanjeet0012 sumanjeet0012 force-pushed the fix-66-default-base32 branch from 005aabd to e7bbd13 Compare July 12, 2026 18:52
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.

1 participant