Socket
Socket
Sign inDemoInstall

hash.js

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hash.js

Various hash functions that could be run by both browser and node


Version published
Weekly downloads
8.5M
decreased by-17.61%
Maintainers
1
Install size
48.7 kB
Created
Weekly downloads
 

Package description

What is hash.js?

The hash.js npm package is a JavaScript library that provides a collection of cryptographic hash functions implemented in pure JavaScript. It is commonly used for creating hash digests of data, which is a crucial aspect of various security protocols and data integrity checks.

What are hash.js's main functionalities?

SHA-1 Hashing

This feature allows you to create SHA-1 hash digests of input data. The code sample demonstrates how to hash the string 'Hello World' using SHA-1 and output the digest in hexadecimal format.

"use strict"; const hash = require('hash.js'); const sha1Hash = hash.sha1().update('Hello World').digest('hex'); console.log(sha1Hash);

SHA-256 Hashing

This feature enables SHA-256 hashing. The code sample shows how to hash the string 'Hello World' using SHA-256 and then output the digest in hexadecimal format.

"use strict"; const hash = require('hash.js'); const sha256Hash = hash.sha256().update('Hello World').digest('hex'); console.log(sha256Hash);

HMAC Generation

This feature is used to generate HMAC (Hash-based Message Authentication Code) using a specified hash function and a secret key. The code sample illustrates generating an HMAC for the string 'Hello World' using the SHA-256 hash function and 'secret-key' as the secret key.

"use strict"; const hash = require('hash.js'); const hmac = hash.hmac(hash.sha256, 'secret-key').update('Hello World').digest('hex'); console.log(hmac);

Other packages similar to hash.js

Readme

Source

hash.js Build Status

Just a bike-shed.

Install

npm install hash.js

Usage

var hash = require('hash.js')
hash.sha256().update('abc').digest('hex')

Selective hash usage

var sha512 = require('hash.js/lib/hash/sha/512');
sha512().update('abc').digest('hex');
LICENSE

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2014.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Last updated on 30 Nov 2018

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