Hi,
I am trying to understand how Cid creation functions work but i face an issue.
import meaning
u "github.com/ipfs/go-ipfs-util"
mc "github.com/multiformats/go-multicodec"
cid "github.com/ipfs/go-cid"
echo "Hello Univers" | ipfs add
Running the previous command produce this CID
QmdeNaZ3WAMjWCmjj6A9JxHPCYJ2gLP1o9zfoYkzpx1Kfq
However when I run this line
fmt.Println(cid.NewCidV0(u.Hash([]byte("Hello Univers"))))
I get this CID
QmWLrKj9DgWWDvcGytgnQtrvYdXwaR6XfvSCeffmZCcGnU
Tried adding a \n but still get the wrong CID
QmcNnD12npk64WECdkxTXv9a5UvbFhNRNgLzK8T2BSToRC
What I truly don’t understand is that it works for Cidv1
if i run this command :
echo "Hello Univers" | ipfs add --cid-version=1
I will get this cid :
bafkreigqr5a34zlu7bowdn4ksh3nn2oqpb7vi5zao6j43jv74ehbgvwhcm
and if I run this line
fmt.Println(cid.NewCidV1(uint64(mc.Raw),u.Hash([]byte("Hello Univers\n"))))
I will get the same CID.
Any ideas on why it works on v1 and not en v0 ?
Thanks