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

前端 未结 12 2210
温柔的废话
温柔的废话 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:43

    There is no way to do so because at the end of the day, the code still has to run, unencrypted, on the client machine, which means the routine to decrypt the code has to be sent alongside the encrypted code. You're handing them both the lock and the key, all they have to do is turn.

    Your best best is to run it through an obfuscator, but even then, its not like somebody won't be able to just rewrite it themselves without the need to attempt to read your code anyway.

提交回复
热议问题