isomorphic-webcrypto ![NPM](https://img.shields.io/npm/v/isomorphic-webcrypto.svg)
isomorphic webcrypto library for IE11+ in 3kB
What?
There's a great Node polyfill for the Web Crypto API, but it's not isomorphic yet. This fills the gap until it is.
IE11 and versions of Safari < 11 use an older version of the spec, so the browser implementation includes a webcrypto-shim to iron out the differences. You'll still need to provide your own Promise polyfill.
Install
npm install isomorphic-webcrypto
Usage
There's a simple example below, but there are many more here.
const crypto = require('isomorphic-webcrypto')
import crypto from 'isomorphic-webcrypto'
crypto.subtle.digest(
{ name: 'SHA-256' },
new Uint8Array([1,2,3]).buffer
)
.then(hash => {
})
Compatibility
See webcrypto-shim's supported browsers for standard browser support.
If you need a js-only implementation for older browsers or environments that don't have any crypto support, the Microsoft Research library is exposed as the extended
version.
const crypto = require('isomorphic-crypto/extended')
crypto.initPrng(randomArrayOf48Bytes)
I just want to drop in a script tag
You should use the webcrypto-shim library directly:
<script src="https://unpkg.com/bluebird"></script>
<script src="https://unpkg.com/webcrypto-shim"></script>
License
MIT