This commit is contained in:
2024-04-16 23:03:54 +08:00
commit 54580cc1b2
723 changed files with 103745 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { _decorator } from 'cc'
import { Logger } from './Logger'
export default class HaoEncrypt {
public static encode(str: string) {
let result: string = ''
for (let i = 0; i < str.length; i++) {
//遍历字符串
let code: number = str.charCodeAt(i) // //逐个提取每个字符并获取Unicode编码值
if (i % 2 == 0) {
code += 2
} else {
code += 1
}
result += String.fromCharCode(code)
}
return result
}
public static decode(str: string) {
let result: string = ''
for (let i = 0; i < str.length; i++) {
//遍历字符串
let code: number = str.charCodeAt(i) // //逐个提取每个字符并获取Unicode编码值
if (i % 2 == 0) {
code -= 2
} else {
code -= 1
}
result += String.fromCharCode(code)
}
return result
}
}