This library provides a single api to use web-crypto and Subtle Crypto in both Node.js using Crypto Module and Web targets using Web Crypto API using Conditional Exports.
Requirements:
- Node.js: Version 15 and above (this library provides no polyfills for older versions!)
- Browser: Secure Context (HTTPS/Localhost) in Supported Browsers
- Other Runtimes: Exposed
globalThis.crypto
andglobalThis.crypto.subtle
. (you can polyfill if neeeded)
Install package:
# npm
npm install uncrypto
# yarn
yarn add uncrypto
# pnpm
pnpm install uncrypto
Import:
// ESM
import { subtle, randomUUID, getRandomValues } from "uncrypto";
// CommonJS
const { subtle, randomUUID, getRandomValues } = require("uncrypto");
- Clone this repository
- Install latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
Made with 💛
Published under MIT License.