Skip to content

Commit b1cc3e4

Browse files
authored
Merge pull request ipfs#85 from ipfs/feat/cidv1-default-base32
default cidv1 to base32
2 parents e7e67e0 + b16425b commit b1cc3e4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This will make sure that dependencies are rewritten to known working versions.
6767

6868
```go
6969
// Create a cid from a marshaled string
70-
c, err := cid.Decode("zdvgqEMYmNeH5fKciougvQcfzMcNjF3Z1tPouJ8C7pc3pe63k")
70+
c, err := cid.Decode("bafzbeigai3eoy2ccc7ybwjfz5r3rdxqrinwi4rwytly24tdbh6yk7zslrm")
7171
if err != nil {...}
7272

7373
fmt.Println("Got CID: ", c)

cid.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func (c Cid) String() string {
368368
case 0:
369369
return c.Hash().B58String()
370370
case 1:
371-
mbstr, err := mbase.Encode(mbase.Base58BTC, c.Bytes())
371+
mbstr, err := mbase.Encode(mbase.Base32, c.Bytes())
372372
if err != nil {
373373
panic("should not error with hardcoded mbase: " + err.Error())
374374
}

cid_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -438,25 +438,25 @@ func TestHexDecode(t *testing.T) {
438438
t.Fatal(err)
439439
}
440440

441-
if c.String() != "zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG" {
441+
if c.String() != "bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm" {
442442
t.Fatal("hash value failed to round trip decoding from hex")
443443
}
444444
}
445445

446446
func ExampleDecode() {
447-
encoded := "zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG"
447+
encoded := "bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm"
448448
c, err := Decode(encoded)
449449
if err != nil {
450450
fmt.Printf("Error: %s", err)
451451
return
452452
}
453453

454454
fmt.Println(c)
455-
// Output: zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
455+
// Output: bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
456456
}
457457

458458
func TestFromJson(t *testing.T) {
459-
cval := "zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG"
459+
cval := "bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm"
460460
jsoncid := []byte(`{"/":"` + cval + `"}`)
461461
var c Cid
462462
err := json.Unmarshal(jsoncid, &c)
@@ -470,7 +470,7 @@ func TestFromJson(t *testing.T) {
470470
}
471471

472472
func TestJsonRoundTrip(t *testing.T) {
473-
exp, err := Decode("zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG")
473+
exp, err := Decode("bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm")
474474
if err != nil {
475475
t.Fatal(err)
476476
}

0 commit comments

Comments
 (0)