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

hash-base

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-base

abstract base class for hash-streams

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6M
decreased by-59.46%
Maintainers
1
Weekly downloads
 
Created

What is hash-base?

The hash-base package is a Node.js module that provides a base implementation for creating hash functions. It is designed to be extended by other modules to create specific hash function implementations. The package simplifies the process of implementing hash algorithms by handling common tasks such as buffering and streaming data.

What are hash-base's main functionalities?

Streaming data through hash function

This code demonstrates how to extend the HashBase class to create a custom hash function. It involves defining the block size in the constructor, implementing the _update method to update the hash state, and the _digest method to produce the final hash output.

"use strict";
const HashBase = require('hash-base');
class MyHash extends HashBase {
  constructor () {
    super(64); // block size
  }
  _update () {
    // update hash state with this._block
  }
  _digest () {
    // return the final hash
    return Buffer.from([]);
  }
}
const hash = new MyHash();
hash.update('Hello, world!');
console.log(hash.digest('hex'));

Other packages similar to hash-base

Keywords

FAQs

Package last updated on 03 Apr 2016

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