https://github.com/andywer/isomorphic-crypto
🔒 Isomorphic crypto package for node and the browser.
https://github.com/andywer/isomorphic-crypto
Last synced: 12 months ago
JSON representation
🔒 Isomorphic crypto package for node and the browser.
- Host: GitHub
- URL: https://github.com/andywer/isomorphic-crypto
- Owner: andywer
- License: mit
- Created: 2017-08-22T21:21:20.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-22T21:27:39.000Z (almost 9 years ago)
- Last Synced: 2025-06-17T21:46:07.418Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isomorphic-crypto [](https://www.npmjs.com/package/isomorphic-crypto)
Isomorphic crypto package for node and the browser. Uses the [native crypto module](https://nodejs.org/api/crypto.html) when run in node and [crypto-browserify](https://www.npmjs.com/package/crypto-browserify) when run in the browser. Use it for hashing, signing and your other crypto needs!
## Installation
```sh
npm install --save isomorphic-crypto
# using yarn:
yarn add isomorphic-crypto
```
## Usage
Have a look at the official [crypto documentation](https://nodejs.org/api/crypto.html).
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](https://www.npmjs.com/package/crypto-browserify) to see what is supported and what not.
## Example
```js
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')}`)
```
## Versioning
The library's major version matches the major version of the [crypto-browserify](https://www.npmjs.com/package/crypto-browserify) package. The minor and patch version can be bumped independently.
## License
MIT