-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPABE.js
62 lines (48 loc) · 1.58 KB
/
CPABE.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { exec } = require("child_process");
const fs = require('fs');
function shell_script() {
exec("cd cpabe; mkdir shell_script", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
//console.log(`stdout: ${stdout}`);
});
}
function cpabe_encryption() {
var file = 'confedential_resource_information.txt';
//read resource name from resoure/resource_name.txt file
var policy_read = fs.readFileSync('/home/rimjhim/front_end/JWT_token/token_simplify/cpabe_ro/resource/resource_policy.txt', 'utf8');
//var policy = '( ( age > 10 and 1 of ( preference = 1, preference = 0 ) ) or ( club_member = 1 ) )';
//var policy = `${policy_read}`;
exec(`cd cpabe_ro; cpabe-enc pub_key ${file} ${policy_read}`, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
//console.log(`stdout: ${stdout}`);
});
}
function cpabe_decryption() {
var file = 'confedential_resource_information.txt.cpabe';
exec(`cd cpabe_ro; cpabe-dec pub_key B_priv_key confedential_resource_information.txt.cpabe`, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}
module.exports = { shell_script, cpabe_encryption, cpabe_decryption};