Socket
Socket
Sign inDemoInstall

sha3

Package Overview
Dependencies
13
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sha3

A Node.js C++ extension for SHA-3 (Keccak)


Version published
Weekly downloads
97K
decreased by-11.97%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

A Node.js C++ extension for SHA-3 (Keccak)

Travis CI npm version npm downloads dependencies devDependencies license

This Node.js extension implements the SHA-3 (Keccak) cryptographic hashing algorithm. It is based on the reference C implementation, version 3.2. The exposed interface is almost identical to that of the crypto standard library.

Phusion

Installation

Via npm:

$ npm install sha3

Via yarn:

$ yarn add sha3

Usage

Keccak supports 5 hash lengths: 224-bit, 256-bit, 384-bit, 512-bit and variable length. Variable length is not supported by this Node.js extension. Unless the user specifies otherwise, this Node.js extension assumes 512-bit.

const SHA3 = require('sha3');

// Generate 512-bit digest.
let d = new SHA3.SHA3Hash();
d.update('foo');
d.digest('hex');
// => "1597842a..."

// Generate 224-bit digest.
d = new SHA3.SHA3Hash(224);
d.update('foo');
d.digest('hex');
// => "daa94da7..."

new SHA3Hash([hashlen])

This is the hash object. hashlen is 512 by default.

hash.update(data, [input_encoding])

Updates the hash content with the given data, the encoding of which is given in input_encoding and can be 'utf8', 'ascii' or 'binary'. Defaults to 'binary'. This can be called many times with new data as it is streamed.

hash.digest([encoding])

Calculates the digest of all of the passed data to be hashed. The encoding can be 'hex' or 'binary'. Defaults to 'binary'.

Note: unlike crypto.Hash, a SHA3Hash object can still be used after the digest() method been called.

Running the test suite

Run the test suite as follows:

$ npm test

The test suite is automatically generated from Keccak's reference test suite. It requires that you have Python 2.7 installed and available via the python executable.

Warning

Do not use SHA-3 for hashing passwords. Do not even use SHA-3 + salt for hashing passwords. Use a slow hash instead.

See also

Digest::SHA3 for Ruby

Keywords

FAQs

Last updated on 01 Dec 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc