1.1.0 • Published 7 months ago

wincrypt v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

WinCrypt

⚠️ Windows Only

WinCrypt is built in rust and uses the native windows api's CryptProtectData and CryptUnprotectData functions

Example

const wincrypt = require("wincrypt");

const text = Buffer.from("test");
const pass = Buffer.from("123");

const encrypted = wincrypt.protectData(text, pass);

console.log(wincrypt.unprotectData(encrypted, pass).toString()); // Prints "test"

Types

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

Without password

wincrypt.protectData(Buffer.from("test"));

With custom flag (only CRYPTPROTECT_LOCAL_MACHINE supported)

INFO: Default flag is 0 ("CurrentUser")

wincrypt.protectData(Buffer.from("test"), null, wincrypt.Flags.LocalMachine);
// or
wincrypt.protectData(Buffer.from("test"), null, "LocalMachine");

The usage for unprotectData method is the same as protectData

© (C) Angelo II Apache-2.0 license, all right reserved

1.1.0

7 months ago

1.0.0-1000

9 months ago

1.0.0-stable

9 months ago

1.5.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago