gpt4 book ai didi

javascript - 混淆: JS protection

转载 作者:行者123 更新时间:2023-11-28 00:52:45 25 4
gpt4 key购买 nike

多年来,我一直在编写大量代码,但在过去,它们从未被要求受到保护,主要是因为代码是为客户而不是我自己编写的。

我写了很多 JavaScript 和 jQuery 代码,我最大的问题是我也有 Ajax 请求,并且这些请求与内部 PHP 文件进行通信。

以下是来自 Google 的代码示例:

function Yf(a, b, c) {
c && (b = r(b, c));
if (document.addEventListener) try {
Zf(document, "DOMContentLoaded", b, a)
} catch (d) {
Zf(window, "load", b, a)
} else if (!document.uniqueID && document.expando) var e = document.createElement("tempnode"),
f = window.setInterval(function() {
try {
e.doScroll("left")
} catch (a) {
return
}
window.clearInterval(f);
f = e = null;
c && (b = r(b, c));
b()
}, 50);
else "readyState" in document ? f = window.setInterval(function() {
/loaded|complete/.test(document.readyState) && (window.clearInterval(f), f = null, c && (b = r(b, c)), b())
},
50) : Zf(window, "load", b, a)
}

========================================

代码来自此网址: http://www.google.com/inbox/assets/js/main.min.js

在线 JavaScript 美化器: http://jsbeautifier.org/

这是混淆还是从一开始就这样写的?(当然,人们可以继续阅读此代码和其他行,但没有证据表明任何 Ajax 请求正在与一个(或多个)内部页面文件进行通信)

类似的问题之前可能已经发布过,但请耐心等待。

最佳答案

通常不会。

所有这些单字母变量通常都是通过 JavaScript 压缩器运行代码的结果。

JavaScript 代码通过 HTTP 发送到浏览器,因此实践中应使代码尽可能紧凑以节省带宽(就 Google 而言,带宽可能很多)。这涉及到使用缩小器,它的作用就像一个编译器,它接受现有的 JS 代码,对其进行转换和优化,使其在功能上相同,但尺寸要小得多。

有关更多详细信息,您可以查看Wikipedia page on minification ,其中指出:

Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments, and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute.

关于javascript - 混淆: JS protection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26574874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com