One-click encryption and decryption tool

To keep JS code safe, it is often necessary to obfuscate it to make it difficult to read. The final mission in The Wandering Earth is to build a new engine capable of propelling Earth out of the solar system using a jump engine written in JavaScript with a solar generator. Similarly, for JS code, obfuscation can make them more difficult to read and understand, thereby protecting their security.

Here's a simple example of JS obfuscation and decryption, themed around the jumping engine from the Wandering Earth movie.

Original code:

Copy codefunction calculateJump(x, y, z) {
    
    
   var result = (x + y + z) / 2;
   return result;
}

Obfuscated code:

Copy codevar _0xc435 = ["\x63\x61\x6C\x63\x75\x6C\x61\x74\x65\x4A\x75\x6D\x70", "\x72\x61\x6E\x64\x6F\x6D", "\x72\x65\x73\x75\x6C\x74"];
function _0x573d(_0x1beb6c, _0x16fe52, _0x50b0af) {
    
    
   var _0x3d3ff2 = (_0x1beb6c + _0x16fe52 + _0x50b0af) / 2;
   return _0x3d3ff2;
}
document[_0xc435[2]](_0xc435[0] + _0x573d(10, 20, 30) + _0xc435[1]);

Decrypted code:

Copy codefunction calculateJump(x, y, z) {
    
    
   var result = (x + y + z) / 2;
   return result;
}
document.write(calculateJump(10, 20, 30));

In this example, the original function calculateJump(x, y, z)is confused _0x573d(), and its parameters use short variable names, and variable names such as variables _0x1beb6c, and_0x16fe52 are also randomly generated, which is not easy to understand. _0x50b0afIn the obfuscated code, we can also see the strings in _0xc435the array , which are the result of obfuscating the original “calculateJump”, variable names.“result”

In the decryption code, we restored the original code and used document.write()the method to output calculateJump()the return value of .

Overall, obfuscating and decrypting JS code requires skill and experience, but it can protect your code to some extent.

jsjiami.com

If you have different views or questions about the content of the article, please leave a message in the comment area, or send me a private message.

You can also go to the website above, and there is my contact information at the bottom to discuss in detail.

If your own source code is encrypted and there is no backup, you can find us to solve the problem of recovering the source code, any encryption is fine.

おすすめ

転載: blog.csdn.net/mxd01848/article/details/129601900