Skip to content

Prebuilt native module (Node.JS) to encrypt data on Windows with DPAPI. Forked from Primno, waiting for the PR to be merged. If nothing is merged, I'll keep this repo because I need the library in MAC/Linux (At least don't throw errors!))

License

Notifications You must be signed in to change notification settings

ArielAlvaradoAtahuichi/dpapi

 
 

Repository files navigation

DPAPI

npm npm build coverage

Native module to encrypt/decrypt data on Windows with DPAPI.

This native module is prebuilt for Node.JS running on Windows. It provides the win32-x64 N-API module.

Based on the port to N-API made by Microsoft in @msal-node-extension from the work of Brad Hughes.

This package is part of the Primno framework.

Why this package?

Other similar packages require to build the native module on the target machine during the installation. This means that you must have Python and Visual C++ installed, production environment included.

This package is prebuilt, so you don't need to have build tools installed on the target machine. It will compile in other OS but you should add a check and use an alternative encrypt/decrypt method.

Install

The win32-x64 prebuilt module will be installed with the following command.

npm install @primno/dpapi

Definition

function protectData(
    userData: Uint8Array,
    optionalEntropy: Uint8Array | null,
    scope: "CurrentUser" | "LocalMachine"
): Uint8Array;

function unprotectData(
    encryptedData: Uint8Array,
    optionalEntropy: Uint8Array | null,
    scope: "CurrentUser" | "LocalMachine"
): Uint8Array;

Usage

import { Dpapi } from "@primno/dpapi";

const buffer = Buffer.from("Hello world", "utf-8");

const encrypted = Dpapi.protectData(buffer, null, "CurrentUser");
const decrypted = Dpapi.unprotectData(encrypted, null, "CurrentUser");

Credits

  • Brad Hughes for the original code.
  • Microsoft for the N-API port in MSAL-Node-Extension.

About

Prebuilt native module (Node.JS) to encrypt data on Windows with DPAPI. Forked from Primno, waiting for the PR to be merged. If nothing is merged, I'll keep this repo because I need the library in MAC/Linux (At least don't throw errors!))

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 54.6%
  • TypeScript 28.2%
  • Python 12.7%
  • C 2.8%
  • JavaScript 1.7%