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

@ethersproject/keccak256

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/keccak256

The keccak256 hash function for ethers.

  • 5.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
increased by7.23%
Maintainers
1
Weekly downloads
 
Created

What is @ethersproject/keccak256?

@ethersproject/keccak256 is a part of the ethers.js library, which is a complete and compact library for interacting with the Ethereum blockchain. The keccak256 module specifically provides functionality for hashing data using the Keccak-256 algorithm, which is a cryptographic hash function used extensively in Ethereum.

What are @ethersproject/keccak256's main functionalities?

Hashing a string

This feature allows you to hash a string using the Keccak-256 algorithm. The `toUtf8Bytes` function is used to convert the string into a byte array, which is then hashed.

const { keccak256 } = require('@ethersproject/keccak256');
const { toUtf8Bytes } = require('@ethersproject/strings');

const data = 'Hello, world!';
const hash = keccak256(toUtf8Bytes(data));
console.log(hash);

Hashing a byte array

This feature allows you to hash a byte array directly using the Keccak-256 algorithm. This is useful for hashing binary data.

const { keccak256 } = require('@ethersproject/keccak256');

const data = new Uint8Array([1, 2, 3, 4, 5]);
const hash = keccak256(data);
console.log(hash);

Hashing a hex string

This feature allows you to hash a hex string using the Keccak-256 algorithm. The `hexlify` function is used to ensure the data is in the correct format.

const { keccak256 } = require('@ethersproject/keccak256');
const { hexlify } = require('@ethersproject/bytes');

const data = '0x123456';
const hash = keccak256(hexlify(data));
console.log(hash);

Other packages similar to @ethersproject/keccak256

Keywords

FAQs

Package last updated on 19 Aug 2022

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