You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Hi, so i am trying to generate IPFS hash of a file but not using ipfs cli. So what I want to achieve is to have js module that generate IPFS hash that have exactly the same IPFS hash when using ipfs cli e.g "ipfs add -n [filename]".
The reason I'm not using js-ipfs is because its overkill, I mean what we need is just the hash generation algorithm nothing else.
I tried it using "js-ipld-dag-pb" to generate the merkle dag hash but when I compare it with "ipfs add -n", the hash result is different. Am I missing some steps in IPFS hash generation?
Steps to reproduce the error:
hash.js
constmultihashes=require('multihashes')constdagPB=require('ipld-dag-pb')import{readFileSync}from'fs'constfileBuffer=readFileSync('./index.js')dagPB.DAGNode.create(fileBuffer,(err,node)=>{if(err)returnconsole.error(err)console.log(multihashes.toB58String(node._cid.multihash))// output QmUkfFWUDiDDTX7pPpXusfVj31RwoQqSyFVgnx1cN7b14R// but [ipfs add index.js] output QmPPopR6vsHuujdQw5SnLY8u4GPCCJyLHLBWyoX7nAYNXn})