Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multihashes

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multihashes

multihash implementation

  • 3.1.3-next.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
696K
increased by8.07%
Maintainers
3
Weekly downloads
 
Created

What is multihashes?

The 'multihashes' npm package provides utilities for creating, decoding, and working with multihashes. Multihashes are self-describing hashes that include information about the hash function used and the length of the hash, making them useful for decentralized systems and content-addressable storage.

What are multihashes's main functionalities?

Encoding a hash

This feature allows you to encode a hash using a specified hash function. In this example, a SHA-256 hash is encoded into a multihash.

const multihashes = require('multihashes');
const hash = Buffer.from('1220' + 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'hex');
const encoded = multihashes.encode(hash, 'sha2-256');
console.log(encoded.toString('hex'));

Decoding a multihash

This feature allows you to decode a multihash to retrieve the original hash and the hash function used. The example decodes a SHA-256 multihash.

const multihashes = require('multihashes');
const encoded = Buffer.from('1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'hex');
const decoded = multihashes.decode(encoded);
console.log(decoded);

Validating a multihash

This feature allows you to validate a multihash to ensure it is correctly formatted. The example checks if a given multihash is valid.

const multihashes = require('multihashes');
const encoded = Buffer.from('1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'hex');
const isValid = multihashes.validate(encoded);
console.log(isValid);

Other packages similar to multihashes

Keywords

FAQs

Package last updated on 15 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc