Socket
Socket
Sign inDemoInstall

@ethersproject/keccak256

Package Overview
Dependencies
2
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/keccak256

The keccak256 hash function for ethers.


Version published
Weekly downloads
869K
increased by9.15%
Maintainers
1
Created
Weekly downloads
 

Package description

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

Readme

Source

KECCAK256 Hash Function

This sub-module is part of the ethers project.

It is responsible for the identify function (i.e. KECCAK256) use in Ethereum.

For more information, see the documentation.

Importing

Most users will prefer to use the umbrella package, but for those with more specific needs, individual components can be imported.

const {

    keccak256

} = require("@ethersproject/keccak256");

License

MIT License

Keywords

FAQs

Last updated on 24 May 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc