@esfaenza/extensions 11.2.11 → 11.2.12
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/bundles/esfaenza-extensions.umd.js +14 -20
- package/bundles/esfaenza-extensions.umd.js.map +1 -1
- package/bundles/esfaenza-extensions.umd.min.js +1 -1
- package/bundles/esfaenza-extensions.umd.min.js.map +1 -1
- package/esfaenza-extensions.metadata.json +1 -1
- package/esm2015/lib/services/extensions.hashing.service.js +14 -21
- package/fesm2015/esfaenza-extensions.js +13 -20
- package/fesm2015/esfaenza-extensions.js.map +1 -1
- package/lib/services/extensions.hashing.service.d.ts +3 -7
- package/package.json +1 -1
|
@@ -1303,33 +1303,27 @@
|
|
|
1303
1303
|
if (navigateFullDepth === void 0) { navigateFullDepth = false; }
|
|
1304
1304
|
if (precise === void 0) { precise = false; }
|
|
1305
1305
|
var strDef = this.stringify(o, level, navigateFullDepth);
|
|
1306
|
-
var hash = precise ? this.md5(strDef) : this.
|
|
1306
|
+
var hash = precise ? this.md5(strDef) : this.simpleHash(strDef);
|
|
1307
1307
|
return hash;
|
|
1308
1308
|
};
|
|
1309
1309
|
/**
|
|
1310
|
-
* Hash più semplice e più veloce dell'md5, ma meno sicuro
|
|
1310
|
+
* Hash più semplice e più veloce dell'md5, ma meno sicuro
|
|
1311
1311
|
*
|
|
1312
|
-
*
|
|
1313
|
-
*/
|
|
1314
|
-
HashingService.prototype.simpleHash = function (str) {
|
|
1315
|
-
var hash = 0;
|
|
1316
|
-
for (var i = 0; i < str.length; i++) {
|
|
1317
|
-
var char = str.charCodeAt(i);
|
|
1318
|
-
hash = (hash << 5) - hash + char;
|
|
1319
|
-
hash &= hash; // Convert to 32bit integer
|
|
1320
|
-
}
|
|
1321
|
-
return new Uint32Array([hash])[0].toString(36);
|
|
1322
|
-
};
|
|
1323
|
-
/**
|
|
1324
|
-
* Hash più semplice e più veloce dell'md5, ma meno sicuro... vediamo come va
|
|
1312
|
+
* Vedi https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
|
1325
1313
|
*
|
|
1326
1314
|
* @param {string} str Stringa di cui calcolare l'hash
|
|
1327
1315
|
*/
|
|
1328
|
-
HashingService.prototype.
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1316
|
+
HashingService.prototype.simpleHash = function (str, seed) {
|
|
1317
|
+
if (seed === void 0) { seed = 0; }
|
|
1318
|
+
var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
1319
|
+
for (var i = 0, ch = void 0; i < str.length; i++) {
|
|
1320
|
+
ch = str.charCodeAt(i);
|
|
1321
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
1322
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
1323
|
+
}
|
|
1324
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
1325
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
1326
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString();
|
|
1333
1327
|
};
|
|
1334
1328
|
/**
|
|
1335
1329
|
* Genera una stringa che identifica univocamente l'oggetto in questione
|