|
@@ -261,6 +261,23 @@ export class ToolsHelper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ static encryptStringToNumber(str: string): number {
|
|
|
+ let result = 0;
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
+ result = result * 256 + str.charCodeAt(i);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ static decryptNumberToString(num: number): string {
|
|
|
+ let result = '';
|
|
|
+ while (num > 0) {
|
|
|
+ result = String.fromCharCode(num & 255) + result;
|
|
|
+ num >>>= 8;
|
|
|
+ }
|
|
|
+ return result.replace(/[\s\0]+$/, ''); // 移除结尾的空白字符
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取调用栈第一个类
|
|
|
*/
|
|
@@ -321,7 +338,7 @@ export class ToolsHelper {
|
|
|
private static setTimeOutMap: Map<string, ThrottleInterface> = new Map()
|
|
|
private static uniqueIdMap = new WeakMap<Function, string>();
|
|
|
|
|
|
- public static getUuid() {
|
|
|
+ public static getUuid() {
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
|
let r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
|
return v.toString(16);
|
|
@@ -334,5 +351,4 @@ export class ToolsHelper {
|
|
|
}
|
|
|
return ToolsHelper.uniqueIdMap.get(fun)!;
|
|
|
}
|
|
|
-
|
|
|
}
|