Socket
Socket
Sign inDemoInstall

sha.js

Package Overview
Dependencies
1
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sha.js

streaming sha1 hash in pure javascript


Version published
Weekly downloads
11M
decreased by-6.38%
Maintainers
1
Created
Weekly downloads
 

Package description

What is sha.js?

The sha.js npm package is a module that provides cryptographic hash functions, specifically SHA (Secure Hash Algorithm) family functions. It allows for the generation of hash values from input data, which is a common requirement in various security contexts, such as password hashing, data integrity checks, and digital signatures.

What are sha.js's main functionalities?

SHA-256 Hash Generation

This feature allows for the generation of SHA-256 hash values from input strings. The code sample demonstrates how to create a SHA-256 hash of the string 'hello world' and output it in hexadecimal format.

"use strict";\nconst sha256 = require('sha.js').sha256;\nconst hash = new sha256().update('hello world').digest('hex');\nconsole.log(hash);

SHA-512 Hash Generation

This feature enables the creation of SHA-512 hash values. The provided code sample shows how to generate a SHA-512 hash for the input 'hello world' and print the result in hex format.

"use strict";\nconst sha512 = require('sha.js').sha512;\nconst hash = new sha512().update('hello world').digest('hex');\nconsole.log(hash);

Other packages similar to sha.js

Readme

Source

sha.js

Streamable SHA1 hash in pure javascript.

build status

testling badge

Example

var createHash = require('sha.js')

var sha1 = createHash('sha1')
var sha256 = createHash('sha256')
var sha512 = createHash'sha512')

var h = sha1.update('abc', 'utf8').digest('hex')
console.log(h) //a9993e364706816aba3e25717850c26c9cd0d89d

supported hashes

sha.js currently implements:

  • sha1
  • sha256
  • sha512

Note

Note, this doesn't actually implement a stream, but wrapping this in a stream is trivial. but is does update incrementally, so you can hash things larger than ram, and also, since it reuses the typedarrays, it uses a constant amount of memory (except when using base64 or utf8 encoding, see code comments)

Acknowledgements

This work is derived from Paul Johnston's ["A JavaScript implementation of the Secure Hash Algorithm"] (http://pajhome.org.uk/crypt/md5/sha1.html)

License

MIT

FAQs

Last updated on 11 Jan 2015

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