1.1.6 • Published 2 years ago
lin-dpapi v1.1.6
lin-dpapi
Lin native module to encrypt/decrypt data. On Windows, it uses DPAPI but for linux
API:
function protectData(
userData: Uint8Array,
optionalEntropy: Uint8Array | null,
scope: "CurrentUser" | "LocalMachine"
): Uint8Array;
function unprotectData(
encryptedData: Uint8Array,
optionalEntropy: Uint8Array | null,
scope: "CurrentUser" | "LocalMachine"
): Uint8Array;
Example:
import * as dpapi from "node-dpapi";
const buffer = Buffer.from("Hello world", "utf-8");
const encrypted = dpapi.protectData(buffer, null, "CurrentUser");
const decrypted = dpapi.unprotectData(encrypted, null, "CurrentUser");
FAQ:
Q: Does this work on all platforms?
A: Currently it just works on Window, but calling the protectData function from any other platform will result in an exception.
Publish note
This package originates from bradhugh/node-dpapi, but he did not publish it to npm. I have taken the liberty of publishing this package so it may be used as a dependency. Thx for https://github.com/daguej/node-dpapi/pull/3 to put the pull requests ;)