Skip to content

#️⃣ Just enough code to calculate the IPFS hash for some data

License

Notifications You must be signed in to change notification settings

alanshaw/ipfs-only-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipfs-only-hash

Build Status dependencies Status JavaScript Style Guide

Just enough code to calculate the IPFS hash for some data

Calculate the IPFS hash for some data without having to install or run an IPFS node. Try it out with npx:

npx ipfs-only-hash <path to file>

Install

npm i ipfs-only-hash

Usage

From the command line

ipfs-only-hash <file>

# or pipe in 
echo "hello world" | ipfs-only-hash

As a library

const Hash = require('ipfs-only-hash')
const data = 'hello world!'
const hash = await Hash.of(data)
console.log(hash) // QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j

API

const Hash = require('ipfs-only-hash')

Hash.of(input, options?): Promise<string>

Calculate the hash for the provided input.

  • input (string|Uint8Array|AsyncIterable<Uint8Array>): The input bytes to calculate the IPFS hash for. Note that Node.js readable streams are async iterable!
  • options (Object): Optional options passed directly to the ipfs-unixfs-importer module. See the API docs for possible values.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw

About

#️⃣ Just enough code to calculate the IPFS hash for some data

Resources

License

Stars

Watchers

Forks

Packages

No packages published