WinCrypt a powerfull alternative to 'dpapi', 'node-dpapi', 'windpapi' or '@primno/dpapi' it use wincrypt.h librairy!
npm install windcryptjs
const windcrypt = require("windcrypt");
const text = Buffer.from("test");
const pass = Buffer.from("123");
const encrypted = windcrypt.protectData(text, pass);
console.log(windcrypt.unprotectData(encrypted, pass).toString()); // Prints "test"
`
Types
`ts
export const enum Flags {
CurrentUser = "CurrentUser",
LocalMachine = "LocalMachine"
}
export function protectData(
data: Buffer,
optionalEntropy?: Buffer | undefined | null,
flags?: Flags | undefined | null
): Buffer;
export function unprotectData(
data: Buffer,
optionalEntropy?: Buffer | undefined | null,
flags?: Flags | undefined | null
): Buffer;
`
Usage
$3
`js
windcrypt.protectData(Buffer.from("test"));
`
$3
> INFO: Default flag is 0 ("CurrentUser")
`js
windcrypt.protectData(Buffer.from("test"), null, windcrypt.Flags.LocalMachine);
// or
windcrypt.protectData(Buffer.from("test"), null, "LocalMachine");
`
> The usage for unprotectData method is the same as protectData`