Isomorphic crypto package for node and the browser. Uses the native crypto module when run in node and crypto-browserify when run in the browser. Use it for hashing, signing and your other crypto needs!
npm install --save isomorphic-crypto
# using yarn:
yarn add isomorphic-crypto
Have a look at the official crypto documentation.
Please be aware that the browser version of this library uses crypto-browserify
, which is only a partial implementation of node's native crypto
module. Check out their documentation to see what is supported and what not.
const crypto = require('isomorphic-crypto')
function sha512 (string) {
const hash = crypto.createHash('sha512')
hash.write(string)
return hash.digest('hex')
}
console.log(`sha512('crypto rocks') = ${sha512('crypto rocks')}`)
The library's major version matches the major version of the crypto-browserify package. The minor and patch version can be bumped independently.
MIT