-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.js
More file actions
18 lines (12 loc) · 772 Bytes
/
test.js
File metadata and controls
18 lines (12 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const dpapi = require('bindings')('node-dpapi');
const entropy = Buffer.from("AHHH!H!H!H!!!!", "utf-8");
const buffer = Buffer.from("Hello World", "utf-8");
const currentUser = dpapi.protectData(buffer, null, "CurrentUser");
const withEntropy = dpapi.protectData(buffer, entropy, 'currentUser');
const localMachine = dpapi.protectData(buffer, null, 'localMachine');
const currentUserClear = dpapi.unprotectData(currentUser, null, 'currentUser');
console.log(`CurrentUser Decrypted: '${currentUserClear}'`);
const withEntropyClear = dpapi.unprotectData(withEntropy, entropy, 'currentUser');
console.log(`WithEntropy Decrypted: '${withEntropyClear}'`);
let clear = dpapi.unprotectData(localMachine, null, 'localMachine');
console.log(`Machine Decrypted: '${clear}'`);