diff --git a/cid/cid.py b/cid/cid.py index 7a604b6..702b1d6 100644 --- a/cid/cid.py +++ b/cid/cid.py @@ -242,7 +242,7 @@ def buffer(self) -> bytes: """ return b"".join([bytes([self.version]), multicodec.add_prefix(self.codec, self.multihash)]) - def encode(self, encoding: str | None = "base58btc") -> bytes: + def encode(self, encoding: str | None = "base32") -> bytes: """ Encoded version of the raw representation diff --git a/newsfragments/66.breaking.rst b/newsfragments/66.breaking.rst new file mode 100644 index 0000000..831d882 --- /dev/null +++ b/newsfragments/66.breaking.rst @@ -0,0 +1 @@ +Change CIDv1.encode() default encoding to base32 to conform with CID specification. diff --git a/tests/test_cid.py b/tests/test_cid.py index d79fc6b..486330d 100644 --- a/tests/test_cid.py +++ b/tests/test_cid.py @@ -69,8 +69,8 @@ def test_buffer(self, cid): assert buffer[1:] == multicodec.add_prefix(self.TEST_CODEC, cid.multihash) def test_encode_default(self, cid): - """#encode defaults to base58btc encoding""" - assert cid.encode() == b"zdj7WhuEjrB52m1BisYCtmjH1hSKa7yZ3jEZ9JcXaFRD51wVz" + """#encode defaults to base32 encoding""" + assert cid.encode() == b"bafybeifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e" @pytest.mark.parametrize("codec", ENCODINGS) def test_encode_encoding(self, cid, codec):