sha.js

Streamable SHA hashes in pure javascript

(MIT AND BSD-3-Clause) 40 个版本
安装
npm install sha.js
yarn add sha.js
pnpm add sha.js
bun add sha.js
README

sha.js

NPM Package Build Status Dependency status

js-standard-style

Node style SHA on pure JavaScript.

var shajs = require('sha.js')

console.log(shajs('sha256').update('42').digest('hex'))
// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049
console.log(new shajs.sha256().update('42').digest('hex'))
// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049

var sha256stream = shajs('sha256')
sha256stream.end('42')
console.log(sha256stream.read().toString('hex'))
// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049

supported hashes

sha.js currently implements:

  • SHA (SHA-0) -- legacy, do not use in new systems
  • SHA-1 -- legacy, do not use in new systems
  • SHA-224
  • SHA-256
  • SHA-384
  • SHA-512

Not an actual stream

Note, this doesn't actually implement a stream, but wrapping this in a stream is trivial. It does update incrementally, so you can hash things larger than RAM, as 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.

LICENSE MIT AND BSD-3-Clause

版本列表
2.4.12 2025-07-01
2.4.11 2018-03-20
2.4.10 2018-01-22
2.4.9 2017-09-25
2.4.8 2016-11-10
2.4.7 2016-11-10
2.4.5 2016-02-25
2.4.4 2015-09-18
2.4.3 2015-09-14
2.4.2 2015-06-05
2.4.1 2015-05-19
2.4.0 2015-04-05
2.3.6 2015-01-14
2.3.5 2015-01-13
2.3.4 2015-01-12
2.3.3 2015-01-12
2.3.2 2015-01-12
2.3.1 2015-01-11
2.3.0 2014-11-18
2.2.7 2014-11-06
2.2.6 2014-09-18
2.2.5 2014-09-16
2.2.4 2014-09-16
2.2.3 2014-09-16
2.2.2 2014-09-16
2.1.8 2014-08-31
2.1.7 2014-07-28
2.1.6 2014-07-19
2.1.5 2014-06-07
2.1.4 2014-06-07
2.1.3 2014-04-27
2.1.1 2014-01-27
2.0.0 2014-01-15
1.3.0 2014-01-06
1.2.2 2014-01-06
1.2.1 2013-12-31
1.2.0 2013-12-31
1.1.0 2013-12-27
1.0.0 2013-12-27
0.0.0 2013-12-27