Skip to content
Advertisement

How can I encrypt JavaScript code so that it’s not decryptable?

I have some JavaScript code I need to encrypt, but I want to be sure no one can decrypt it.

What tools can I use to do this?

— Edit —

I still want to run the code on my site, I just want to make sure no one else can decrypt the code.

Advertisement

Answer

The Javascript code is executed in the browser, i.e. on the client side, which means it must be available not-encrypted on the client side.

The “best” you can do is probably to minify it, which will make it harder to understand it — and a bit of obfuscation might do too — even if someone really motivated will still be able to read it.

See for instance the YUI Compressor, which can both minify and obfuscate JS code.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement