Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypt jQuery javascript file

I have a whole range of jQuery code, how do I stop users from seeing the actual code, or how can I encrypt the .js file.

Please suggest opensource

Thanks Jean

[edit] I don't want users to know how I have coded or copy my code

[edit] Once I use the base62 encode, can it be reverse engineered?

like image 603
X10nD Avatar asked Dec 14 '22 00:12

X10nD


2 Answers

Check out packer by Dean Edwards. It has the ability to encode your JS. You have to let your JS be world readable, otherwise a browser couldn't download it.

like image 128
Jarrett Meyer Avatar answered Dec 15 '22 12:12

Jarrett Meyer


You cannot prevent your users from being able to see the source code of a Javascript file : it's executed by the user's browser, which means it must be readable on the client side.

The "best" you can do it minify/obfuscate it ; see for instance the YUI Compressor, which exists to minify JS files (so they are smaller, and can be transferred faster), but also has some obfuscating functionnalities.

If will make you Javascript code harder to read/understand -- but someone really motivated will still be able to read it ; well, it will take some time and a bit of work, but it'll still be possible.

like image 38
Pascal MARTIN Avatar answered Dec 15 '22 13:12

Pascal MARTIN