@medicus.ai/medicus-report-pdf-generator 1.0.225 → 1.0.227

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 CHANGED
@@ -96,11 +96,15 @@ module.exports = {
96
96
  let ecbDecrypted = encryptDecrypt.ecbDecrypt(sentData.toString(), encryptionKey)
97
97
 
98
98
  let xorDecrypted = encryptDecrypt.XORDecrypt(ecbDecrypted, encryptionKey)
99
+ console.log("xorDecrypted",xorDecrypted)
100
+
101
+ let base64Object = Buffer.from(xorDecrypted, 'utf8').toString('base64');
102
+ console.log("base64Object",base64Object)
99
103
  return {
100
104
  ecbDecrypted:ecbDecrypted,
101
- xorDecrypted:xorDecrypted
105
+ xorDecrypted:xorDecrypted,
106
+ base64Object:base64Object
102
107
  }
103
- let base64Object = Buffer.from(xorDecrypted, 'utf8').toString('base64');
104
108
  let LOGS = '';
105
109
  let LOGS_FILE_PATH = __dirname + '/output/LOGS.txt';
106
110
  let PDF_FILE_PATH = __dirname + '/output/nasco-sample.pdf';
@@ -1,4 +1,5 @@
1
1
  const CryptoJS = require('crypto-js');
2
+ const xorCrypt =require('xor-crypt')
2
3
 
3
4
  function ecbEncrypt(data, key) {
4
5
  let encJson = CryptoJS.AES.encrypt(JSON.stringify(data), key).toString();
@@ -15,39 +16,11 @@ function ecbDecrypt(data, key) {
15
16
 
16
17
 
17
18
  function XORDecrypt(input, key) {
18
- console.log("key",key)
19
- key = typeof key === 'object' ? JSON.stringify(key) : key.toString();
20
- var decodedText = atob(input);
21
- var plainText = '';
22
- var length = decodedText.length;
23
-
24
- for (var i = 0; i < length; i++) {
25
- plainText += String.fromCharCode(decodedText.charCodeAt(i) ^ key.charCodeAt(Math.floor(i % key.length)));
26
- }
27
-
28
- return plainText;
19
+ return xorCrypt(input, key);
29
20
  }
30
21
 
31
22
  function XOREncrypt(input, key){
32
- var c = '';
33
- while (key.length < input.length) {
34
- key += key;
35
- }
36
- for(var i=0; i<input.length; i++) {
37
- var value1 = input[i].charCodeAt(0);
38
- var value2 = key[i].charCodeAt(0);
39
-
40
- var xorValue = value1 ^ value2;
41
-
42
- var xorValueAsHexString = xorValue.toString("16");
43
-
44
- if (xorValueAsHexString.length < 2) {
45
- xorValueAsHexString = "0" + xorValueAsHexString;
46
- }
47
-
48
- c += xorValueAsHexString;
49
- }
50
- return c;
23
+ return xorCrypt(input, key);
51
24
  }
52
25
 
53
26
  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.225",
3
+ "version": "1.0.227",
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": {
@@ -16,6 +16,7 @@
16
16
  "canvas": "^2.6.1",
17
17
  "canvas-constructor": "^3.2.0",
18
18
  "chart.js": "^2.7.3",
19
+ "crypto-js": "^4.1.1",
19
20
  "express": "^4.16.4",
20
21
  "get-canvas-context": "^1.0.2",
21
22
  "hummus": "1.0.111",
@@ -31,8 +32,7 @@
31
32
  "qr-image": "^3.2.0",
32
33
  "qrcode": "^1.3.3",
33
34
  "self-adapt-fontsize": "^1.0.6",
34
- "textfit": "^2.3.1",
35
- "crypto-js": "^4.1.1"
35
+ "textfit": "^2.3.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@babel/core": "^7.2.2",
@@ -41,6 +41,7 @@
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"
44
+ "webpack": "^4.28.4",
45
+ "xor-crypt": "^1.1.1"
45
46
  }
46
47
  }