Advertisement
728x90
Obfuscation is the deliberate act of creating obfuscated javascript code(i.e, source or machine code) that is difficult for humans to understand. It is something similar to encryption, but a machine can understand the code and execute it.
Let's see the below function before Obfuscation,
javascript
1function greeting() {
2 console.log("Hello, welcome to JS world");
3 }And after the code Obfuscation, it would be appeared as below,
javascript
1eval(
2 (function (p, a, c, k, e, d) {
3 e = function (c) {
4 return c;
5 };
6 if (!"".replace(/^/, String)) {
7 while (c--) {
8 d[c] = k[c] || c;
9 }
10 k = [
11 function (e) {
12 return d[e];
13 },
14 ];
15 e = function () {
16 return "\\w+";
17 };
18 c = 1;
19 }
20 while (c--) {
21 if (k[c]) {
22 p = p.replace(new RegExp("\\b" + e(c) + "\\b", "g"), k[c]);
23 }
24 }
25 return p;
26 })(
27 "2 1(){0.3('4, 7 6 5 8')}",
28 9,
29 9,
30 "console|greeting|function|log|Hello|JS|to|welcome|world".split("|"),
31 0,
32 {}
33 )
34 );Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 10
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
267of476