Giter Club home page Giter Club logo

sha.js's Introduction

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"] (http://pajhome.org.uk/crypt/md5/sha1.html)

License

MIT

sha.js's People

Contributors

tangcreditdeveloper avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Forkers

wsyandy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.