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

@accumulators/hashers

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accumulators/hashers

A TypeScript implementation of multiple hashing functions

  • 4.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Hashers

@accmulators/hashers library implements the following hashing algorithms:

  • Keccak
  • Poseidon
  • Stark Poseidon
  • Stark Pedersen

Example

import { KeccakHasher } from "@accmulators/hashers";

const hasher = new KeccakHasher();

const hash = hasher.hash([`0x1234`, `0x5678`]);

console.log(hash);

Functions

Every hasher supports the following functions:

constructor(options: HasherOptions) - creates a new hasher instance

Imporant: Don't use constructor for PoseidonHasher, use async create() function instead.

HasherOptions has the following interface:

interface HasherOptions {
  blockSizeBits: number;
  shouldPad?: boolean;
}
  • blockSizeBits (default is 256)
  • shouldPad (defaults is false) - if true every outputted hash will have the same length and zeros will be padded at the beginning of the string
hashSingle(data: string)

Hashes a single string. Returns a hexadecimal number as a string (for example 0x1234567890abcdef).

hash(data: string[])

Hashes array of string and returns a hexadecimal number as a string.

FAQs

Package last updated on 06 Oct 2023

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