Socket
Socket
Sign inDemoInstall

keccak

Package Overview
Dependencies
9
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

keccak

Keccak sponge function family


Version published
Weekly downloads
700K
decreased by-11.82%
Maintainers
1
Created
Weekly downloads
 

Package description

What is keccak?

The keccak npm package provides an implementation of the Keccak cryptographic hash function, which is the basis for the SHA-3 (Secure Hash Algorithm 3) standard. It allows developers to generate hash digests of data, which can be used for data integrity verification, digital signatures, and other cryptographic applications.

What are keccak's main functionalities?

Hashing a string

This feature allows you to hash a string using the Keccak-256 algorithm. The code sample demonstrates how to hash the string 'hello world' and output the resulting hash in hexadecimal format.

const keccak = require('keccak');
const hash = keccak('keccak256').update('hello world').digest('hex');
console.log(hash);

Hashing a buffer

This feature allows you to hash a buffer using the Keccak-256 algorithm. The code sample demonstrates how to hash a buffer containing the string 'hello world' and output the resulting hash in hexadecimal format.

const keccak = require('keccak');
const buffer = Buffer.from('hello world');
const hash = keccak('keccak256').update(buffer).digest('hex');
console.log(hash);

Hashing with different Keccak variants

This feature allows you to use different variants of the Keccak algorithm, such as Keccak-256 and Keccak-512. The code sample demonstrates how to hash the string 'hello world' using both Keccak-256 and Keccak-512, and output the resulting hashes in hexadecimal format.

const keccak = require('keccak');
const hash256 = keccak('keccak256').update('hello world').digest('hex');
const hash512 = keccak('keccak512').update('hello world').digest('hex');
console.log('Keccak-256:', hash256);
console.log('Keccak-512:', hash512);

Other packages similar to keccak

Readme

Source

keccak

VersionMac/LinuxWindows
NPM PackageBuild StatusAppVeyor

js-standard-style

This module provides native bindings to Keccak sponge function family from Keccak Code Package. In browser pure JavaScript implementation will be used.

Usage

You can use this package as node Hash.

const createKeccakHash = require('keccak')

console.log(createKeccakHash('keccak256').digest().toString('hex'))
// => c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470

console.log(createKeccakHash('keccak256').update('Hello world!').digest('hex'))
// => ecd0e108a98e192af1d2c25055f4e3bed784b5c877204e73219a5203251feaab

Also object has two useful methods: _resetState and _clone

const createKeccakHash = require('keccak')

console.log(createKeccakHash('keccak256').update('Hello World!')._resetState().digest('hex'))
// => c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470

const hash1 = createKeccakHash('keccak256').update('Hello')
const hash2 = hash1._clone()
console.log(hash1.digest('hex'))
// => 06b3dfaec148fb1bb2b066f10ec285e7c9bf402ab32aa78a5d38e34566810cd2
console.log(hash1.update(' world!').digest('hex'))
// => throw Error: Digest already called
console.log(hash2.update(' world!').digest('hex'))
// => ecd0e108a98e192af1d2c25055f4e3bed784b5c877204e73219a5203251feaab

Why I should use this package?

I thought it will be popular question, so I decide write explanation in readme.

I know a few popular packages on npm related with Keccak:

LICENSE

This library is free and open-source software released under the MIT license.

Keywords

FAQs

Last updated on 02 Dec 2017

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