Using PHP to prevent users from downloading code, but the code is cpu intensive

I have some proprietary formulas that are used to calculate some characteristics of a car. I have it all in a php file and the user is accessing this from ajax in javascript on the client side.

I believe that in doing so, the user will never be able to access the formulas in the php script, is this true (if I have the access setting correctly)?

The actual problem that I have is probably 80 equations, and this runs 200 times in a loop to get final answers and processor intensity. Running 1 is fine, but if I had 10 people using the site, it would slow down the server.

I can’t put all the formulas on the client side, otherwise he will be able to download them. And I can’t say 90% of the equations on the client side and leave the rest on the server, because then I would have to go back and forth with ajax 200 times inside the loop to get the answers once.

What are my options to do client-side material, but protect formulas?

+4
source share
1 answer

You cannot run code on the client side without allowing the client side to see this code. You can confuse your code, but for something like mathematical equations, I doubt that it will be very difficult for you to obfuscate, which you can do that will eclipse the content so that someone does not understand what equations are.

Your options:

  • Invest in some better hardware so your server can handle more users. This may mean performing calculations at a level different from your web server.
  • Optimize your equations. This could mean re-embedding them in C as a PHP extension module, or at least to provide caching of the operation code.
+2
source

Source: https://habr.com/ru/post/1433254/


All Articles