@acusti/webcrypto
v1.0.2
Published
Isomorphic method for accessing the webcrypto API both from node.js and from the browser (including workers)
Downloads
1,103
Maintainers
Readme
@acusti/webcrypto
webcrypto
exports window.crypto
/ self.crypto
for use in a browser
environment (regular or worker) and the equivalent of
require('node:crypto').webcrypto
for use in node.js.
When used in node, it requires node.js v15.0.0 or later.
Usage
npm install @acusti/webcrypto
# or
yarn add @acusti/webcrypto
import webcrypto from '@acusti/webcrypto';
const uuid = webcrypto.randomUUID();
const data = new TextEncoder().encode('data to hash');
const digest = await webcrypto.subtle.digest({ name: 'SHA-256' }, data);