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

前端 未结 12 2199
温柔的废话
温柔的废话 2020-12-01 15:07

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 --

12条回答
  •  不知归路
    2020-12-01 15:26

    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.

提交回复
热议问题