ztechno_core 0.0.19 → 0.0.21

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.
@@ -9,16 +9,19 @@ export declare class ZCryptoService {
9
9
  static hash(
10
10
  hashAlgorithm: 'sha256' | 'sha512' | 'md5',
11
11
  data: string,
12
- opt?:
12
+ opt?: {
13
+ itt?: number;
14
+ } & (
13
15
  | {
14
16
  saltMode: 'none';
15
17
  }
16
18
  | {
17
19
  saltMode: 'simple';
18
20
  salt: string;
19
- },
21
+ }
22
+ ),
20
23
  ): {
21
- salt: any;
24
+ salt: string;
22
25
  data: string;
23
26
  hash: string;
24
27
  };
@@ -72,18 +72,23 @@ class ZCryptoService {
72
72
  }
73
73
  }
74
74
  static hash(hashAlgorithm, data, opt) {
75
+ const itt = opt?.itt || 1;
75
76
  let salt;
76
77
  if (opt && opt.saltMode === 'simple') {
77
78
  salt = opt.salt;
78
79
  data = data
79
80
  .split('')
80
- .map((c, i) => c + salt.charAt(salt.length % i))
81
+ .map((c, i) => c + salt.charAt(i % salt.length))
81
82
  .join('');
82
83
  }
84
+ let hash = data;
85
+ for (let i = 0; i < itt; i++) hash = crypto.createHash(hashAlgorithm).update(hash).digest('hex');
86
+ const cut = itt.toString().length + 1;
87
+ hash = `${cut}$${hash.substring(cut)}`;
83
88
  return {
84
89
  salt,
85
90
  data,
86
- hash: crypto.createHash(hashAlgorithm).update(data).digest('hex'),
91
+ hash,
87
92
  };
88
93
  }
89
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",