共计 453 个字符,预计需要花费 2 分钟才能阅读完成。
// 对字符串加密
export function decodeStr(code) {let c = String.fromCharCode(code.charCodeAt(0) + code.length);
for (let i = 1, len = code.length; i < len; i++) {c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1));
}
return decodeURI(c);
}
// 字符串进行解密
export function uncodeStr(code) {code = decodeURIComponent(code);
let c = String.fromCharCode(code.charCodeAt(0) - code.length);
for (let i = 1, len = code.length; i < len; i++) {c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1));
}
return c;
}
正文完
发表至: javascript
2021-08-12