@medicus.ai/medicus-report-pdf-generator 1.0.227 → 1.0.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -7
- package/lib/encrypt_decrypt.js +29 -3
- package/package.json +2 -3
package/index.js
CHANGED
|
@@ -93,18 +93,13 @@ module.exports = {
|
|
|
93
93
|
let reportData = JSON.parse(data)
|
|
94
94
|
let encryptionKey=reportData.encryptionKey
|
|
95
95
|
let sentData=reportData.data
|
|
96
|
-
let ecbDecrypted = encryptDecrypt.ecbDecrypt(sentData
|
|
96
|
+
let ecbDecrypted = encryptDecrypt.ecbDecrypt(sentData, encryptionKey)
|
|
97
97
|
|
|
98
98
|
let xorDecrypted = encryptDecrypt.XORDecrypt(ecbDecrypted, encryptionKey)
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
|
|
101
101
|
let base64Object = Buffer.from(xorDecrypted, 'utf8').toString('base64');
|
|
102
102
|
console.log("base64Object",base64Object)
|
|
103
|
-
return {
|
|
104
|
-
ecbDecrypted:ecbDecrypted,
|
|
105
|
-
xorDecrypted:xorDecrypted,
|
|
106
|
-
base64Object:base64Object
|
|
107
|
-
}
|
|
108
103
|
let LOGS = '';
|
|
109
104
|
let LOGS_FILE_PATH = __dirname + '/output/LOGS.txt';
|
|
110
105
|
let PDF_FILE_PATH = __dirname + '/output/nasco-sample.pdf';
|
|
@@ -134,6 +129,7 @@ module.exports = {
|
|
|
134
129
|
}
|
|
135
130
|
// 2: save decoded json string
|
|
136
131
|
const json = Buffer.from(base64Object, 'base64').toString('utf8');
|
|
132
|
+
console.log("json",json)
|
|
137
133
|
if (isDebugging) {
|
|
138
134
|
console.log('2: save decoded json string');
|
|
139
135
|
LOGS += '2: save decoded json string' + '\n' + '=============' + '\n';
|
package/lib/encrypt_decrypt.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const CryptoJS = require('crypto-js');
|
|
2
|
-
const xorCrypt =require('xor-crypt')
|
|
3
2
|
|
|
4
3
|
function ecbEncrypt(data, key) {
|
|
5
4
|
let encJson = CryptoJS.AES.encrypt(JSON.stringify(data), key).toString();
|
|
@@ -16,11 +15,38 @@ function ecbDecrypt(data, key) {
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
function XORDecrypt(input, key) {
|
|
19
|
-
|
|
18
|
+
var decodedText = atob(input);
|
|
19
|
+
console.log("decodedText",input)
|
|
20
|
+
var plainText = '';
|
|
21
|
+
var length = decodedText.length;
|
|
22
|
+
|
|
23
|
+
for (var i = 0; i < length; i++) {
|
|
24
|
+
plainText += String.fromCharCode(decodedText.charCodeAt(i) ^ key.charCodeAt(Math.floor(i % key.length)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return plainText;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
function XOREncrypt(input, key){
|
|
23
|
-
|
|
31
|
+
var c = '';
|
|
32
|
+
while (key.length < input.length) {
|
|
33
|
+
key += key;
|
|
34
|
+
}
|
|
35
|
+
for(var i=0; i<input.length; i++) {
|
|
36
|
+
var value1 = input[i].charCodeAt(0);
|
|
37
|
+
var value2 = key[i].charCodeAt(0);
|
|
38
|
+
|
|
39
|
+
var xorValue = value1 ^ value2;
|
|
40
|
+
|
|
41
|
+
var xorValueAsHexString = xorValue.toString("16");
|
|
42
|
+
|
|
43
|
+
if (xorValueAsHexString.length < 2) {
|
|
44
|
+
xorValueAsHexString = "0" + xorValueAsHexString;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
c += xorValueAsHexString;
|
|
48
|
+
}
|
|
49
|
+
return c;
|
|
24
50
|
}
|
|
25
51
|
|
|
26
52
|
module.exports =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicus.ai/medicus-report-pdf-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.228",
|
|
4
4
|
"description": "Nasco corporate report - latest update in 2/11/2022 - Fix sanusx coprorate report issues",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"babel-polyfill": "^6.26.0",
|
|
42
42
|
"babel-preset-es2015": "^6.24.1",
|
|
43
43
|
"babel-preset-stage-0": "^6.24.1",
|
|
44
|
-
"webpack": "^4.28.4"
|
|
45
|
-
"xor-crypt": "^1.1.1"
|
|
44
|
+
"webpack": "^4.28.4"
|
|
46
45
|
}
|
|
47
46
|
}
|