alanshaw / ipfs-only-hash

#️⃣ Just enough code to calculate the IPFS hash for some data
MIT License
135 stars 28 forks source link

hashAlg not set #24

Open robinsonkwame opened 2 years ago

robinsonkwame commented 2 years ago

e.g., passing in hashAlg has no effect,

const Hash = await require('pure-ipfs-only-hash')
const data = Buffer.from('hello world\n')
hashAlg = 'sha2-256'
cidVersion = 0

await Hash.of(data, {cidVersion, hashAlg})
# 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
# ... but
hashAlg = 'blake2b-8'

await Hash.of(data, {cidVersion, hashAlg})
# 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'

even though the options object of ipfs-unixfs-importer is supported. For example, setting cidVersion = 1 works as expected.

Should I be using js-multiformats instead?