@xuda.io/xuda-worker-bundle-min 1.3.2275 → 1.3.2276

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.
Files changed (2) hide show
  1. package/index.js +34 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1050,27 +1050,40 @@ func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data
1050
1050
  });
1051
1051
  };
1052
1052
 
1053
- func.common.sha256 = async function (inputString) {
1054
- // 1. Create a hash buffer from the input string using SHA-256.
1055
- // This part remains the same as it provides a strong, unique cryptographic starting point.
1056
- const buffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(inputString));
1057
-
1058
- // 2. Interpret the first 8 bytes (64 bits) of the hash as one big number.
1059
- const view = new DataView(buffer);
1060
- const bigInt = view.getBigUint64(0, false); // `false` for big-endian
1061
-
1062
- // 3. Convert the BigInt to a Base36 string.
1063
- // The .toString(36) method handles the conversion to an alphanumeric representation (0-9, a-z).
1064
- const base36Hash = bigInt.toString(36);
1065
-
1066
- // 4. Take the first 10 characters. If it's shorter, it will just return the whole string.
1067
- // For a 64-bit integer, the Base36 representation will be about 13 characters long,
1068
- // so slicing is a reliable way to get a fixed length.
1069
- const shortHash = base36Hash.slice(0, 10);
1070
-
1071
- // 5. Pad the start in the unlikely case the hash is shorter than 10 characters.
1072
- // This ensures the output is always exactly 10 characters long.
1073
- return shortHash.padStart(10, '0');
1053
+ // func.common.sha256 = async function (inputString) {
1054
+ // // 1. Create a hash buffer from the input string using SHA-256.
1055
+ // // This part remains the same as it provides a strong, unique cryptographic starting point.
1056
+ // const buffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(inputString));
1057
+
1058
+ // // 2. Interpret the first 8 bytes (64 bits) of the hash as one big number.
1059
+ // const view = new DataView(buffer);
1060
+ // const bigInt = view.getBigUint64(0, false); // `false` for big-endian
1061
+
1062
+ // // 3. Convert the BigInt to a Base36 string.
1063
+ // // The .toString(36) method handles the conversion to an alphanumeric representation (0-9, a-z).
1064
+ // const base36Hash = bigInt.toString(36);
1065
+
1066
+ // // 4. Take the first 10 characters. If it's shorter, it will just return the whole string.
1067
+ // // For a 64-bit integer, the Base36 representation will be about 13 characters long,
1068
+ // // so slicing is a reliable way to get a fixed length.
1069
+ // const shortHash = base36Hash.slice(0, 10);
1070
+
1071
+ // // 5. Pad the start in the unlikely case the hash is shorter than 10 characters.
1072
+ // // This ensures the output is always exactly 10 characters long.
1073
+ // return shortHash.padStart(10, '0');
1074
+ // };
1075
+
1076
+ func.common.fastHash = function (inputString) {
1077
+ let hash = 0x811c9dc5; // FNV offset basis
1078
+
1079
+ for (let i = 0; i < inputString.length; i++) {
1080
+ hash ^= inputString.charCodeAt(i);
1081
+ // FNV prime multiplication with 32-bit overflow
1082
+ hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
1083
+ }
1084
+
1085
+ // Convert to base36 and pad to 10 characters
1086
+ return ((hash >>> 0).toString(36) + '0000000000').slice(0, 10);
1074
1087
  };
1075
1088
 
1076
1089
  glb.new_xu_render = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.2275",
3
+ "version": "1.3.2276",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {