Encrypt javascript link

Asked

Viewed 1,074 times

1

Hello! I’m needing to encrypt a script, but when I do that the url I’m using as an API for ajax doesn’t work. And the most important thing would be to hide it.

  • I think your question would look better with an example, without the URL you want to hide, of course. A generic example.

1 answer

1

This text was not done by me, but I found it useful to share with the staff.

Virtually every web developer has experienced this problem. Javascript is today one of the leading programming languages of the internet, and often, we developers need to create more complex applications using the language. And after hours of study and dedication, there’s that need for PHP... hide our code so that no one can copy it, since javascript allows it to be copied directly by the browser. Here’s a simple solution to totally overshadow your code, making it virtually impossible to decipher.

Well that Javascript could be like PHP.... I already thought, and probably you web programmer already thought too. Just knowing that all our javascript work will be visible to anyone, we stop and think twice before using a client-side language. Recently, I had problems with a javascript application that I developed... plagiarism. So I started researching the subject and reached a verdict..

It is not possible to hide 100% javascript, because it is processed directly in the browser... However, it is possible obfuscate. So your code is virtually impossible to understand.

Step 1: Compress Your Javascript

Access the site http://javascriptcompressor.com/, Enter your source code and click compress. This will help your code to be reduced in size as this tool will remove whitespace, tabs and comments. I recommend keeping a saved version of the original code:

inserir a descrição da imagem aqui

Step 2: Code Obfuscation

Here is the solution to this problem. The site http://www.javascriptobfuscator.com/, does something that many online tools don’t. It obfuscates your javascript code with the Eval function, and leaves it totally incomprehensible to humans. There are even other obfuscating tools, but this one I found is the best of all, because it does not allow decryption...

To use it, paste your code into the field Input, clear the option "Move Strings" and click on "Obfuscate."

inserir a descrição da imagem aqui

After that, your encrypted code will be generated in the field "Obfuscated".

Step 3: Using a 2nd encryption

To make it even more difficult to view your javascript code, we can use a second online tool to encrypt / obfuscate our javascript code. Just go to the site http://www.phpblog.com.br/exemplos/encodejavascript/, paste your previously encrypted code, choose the form of encryption and click on "encode". I recommend choosing the encoding "High ASCII", leave marked option "rapid decoding" and uncheck the option "special characters" inserir a descrição da imagem aqui

Anyway... I recommend to always keep a backup (backup) of the original JS code, otherwise you won’t be able to understand your code anymore, in case you change anything from it. Although the obfuscation of code makes life very difficult for some smart guy who wants to copy his code, it is still possible to decode. However, the person has to have a lot of patience, hours and hours available and the fundamental, has to be much, much more good in programming and reverse engineering. That is, 99.9% of users and programmers will give up when they see the encrypted code.

Font: Blog Lucas Peperaio

  • I’ll give you 1 for the effort. But the recommended is not to post articles that you find in full on the internet, but you make a response with what you understood with your own text and quote the source. ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.