How to use node-webcrypto-ossl - 1 common examples

To help you get started, we’ve selected a few node-webcrypto-ossl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / node-webcrypto-p11 / test / node-webcrypto-p11-tests.ts View on Github external
/// 

import {Provider, WebCrypto } from "node-webcrypto-ossl";

// Webcrypto constructor
let crypto = new WebCrypto({
    library: "softhsm2.so",
    name: "SoftHSM",
    slot: 0,
    sessionFlags: 6,
    pin: "psw"
});

// Webcrypto getRandomValues 
crypto.getRandomValues(new Buffer(16));
crypto.getRandomValues(new Uint8Array(16));
crypto.getRandomValues(new Uint8Array(16).buffer);

// Webcrypto Storage
let key: NodeWebcryptoPkcs11.CryptoKey;
key = crypto.keyStorage.getItem("keyname");
crypto.keyStorage.length === 0;

node-webcrypto-ossl

A WebCrypto Polyfill for Node in TypeScript built on OpenSSL

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular node-webcrypto-ossl functions