### Install @primno/dpapi Source: https://github.com/primno/dpapi/blob/main/README.md Installs the @primno/dpapi package using npm. This command fetches and installs the prebuilt native module for the current Node.js environment. ```bash npm install @primno/dpapi ``` -------------------------------- ### DPAPI Usage with CommonJS Source: https://github.com/primno/dpapi/blob/main/README.md Illustrates the usage of the Dpapi class and isPlatformSupported flag in a CommonJS environment. It includes a platform check and performs encryption/decryption of a string with the CurrentUser scope. ```javascript const { Dpapi, isPlatformSupported } = require("@primno/dpapi"); if (isPlatformSupported) { const buffer = Buffer.from("Hello world", "utf-8"); const encrypted = Dpapi.protectData(buffer, null, "CurrentUser"); const decrypted = Dpapi.unprotectData(encrypted, null, "CurrentUser"); } else { console.error("Platform not supported. Only Windows is supported (x64, ARM64)"); } ``` -------------------------------- ### DPAPI Usage with ECMAScript Modules Source: https://github.com/primno/dpapi/blob/main/README.md Demonstrates how to use the Dpapi class and isPlatformSupported flag within an ECMAScript module. It checks for platform compatibility before encrypting and decrypting a sample string using the CurrentUser scope. ```javascript import { Dpapi, isPlatformSupported } from "@primno/dpapi"; if (isPlatformSupported) { const buffer = Buffer.from("Hello world", "utf-8"); const encrypted = Dpapi.protectData(buffer, null, "CurrentUser"); const decrypted = Dpapi.unprotectData(encrypted, null, "CurrentUser"); } else { console.error("Platform not supported. Only Windows is supported (x64, ARM64)"); } ``` -------------------------------- ### DPAPI Class Definition Source: https://github.com/primno/dpapi/blob/main/README.md Defines the Dpapi class with methods for protecting and unprotecting data, and a boolean flag indicating platform support. ProtectData encrypts data, while UnprotectData decrypts it, both accepting optional entropy and a scope. ```typescript class Dpapi { public protectData( userData: Uint8Array, optionalEntropy: Uint8Array | null, scope: "CurrentUser" | "LocalMachine" ): Uint8Array; public unprotectData( encryptedData: Uint8Array, optionalEntropy: Uint8Array | null, scope: "CurrentUser" | "LocalMachine" ): Uint8Array; } const isPlatformSupported: boolean; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.