huanggang 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
..
test 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
.npmignore 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
.travis.yml 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
LICENSE 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
README.md 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
bin.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
hash.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
hexpp.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
index.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
package.json 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha1.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha224.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha256.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha384.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos
sha512.js 03a863fb53 add node_modules %!s(int64=7) %!d(string=hai) anos

README.md

sha.js

Streamable SHA hashes in pure javascript.

build status NPM

Example

var createHash = require('sha.js')

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

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

//LEGACY, do not use in new systems:
var sha0 = createHash('sha')
var sha1 = createHash('sha1')


supported hashes

sha.js currently implements:

  • sha256
  • sha512
  • sha1 (legacy, no not use in new systems)
  • sha (legacy, no not use in new systems)

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"

License

MIT