-2

Kindly looking to hide code from view code / inspect element is this safe to use ? I saw this anser here How to hide form code from view code/inspect element browser?

eval(function(p,a,c,k,e,d){e=function(c){return 
c.toString(36)};if(!''.replace(/^/,String)){while(c--)
{d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return 
d[e]}];e=function(){return'\\w+'};c=1};while(c--)
{if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),
k[c])}}return p}('(3(){(3 a(){8{(3 b(2)
{7((\'\'+(2/2)).6!==1||2%5===0){(3(){}).9(\'4\')()}
c{4}b(++2)})(0)}d(e){g(a,f)}})()})();',17,17,'
||i|function|debugger|20|length|if|try|constructor
|||else|catch||5000|setTimeout'.split('|'),0,{}))
Amine ES
  • 23
  • 3
  • Safe how? It's obfuscated code, I can't understand it in its current form without taking some time to analyze it. Are you asking if obfuscating your code like this will prevent people from stealing your code? What kind of an answer are you looking for? – Codebling Feb 08 '21 at 06:02
  • Yes when adding this script it will make a error when user trying to inspect the code – Amine ES Feb 08 '21 at 06:05
  • I mean is it safe to use and is not gonna impact the website's security nor search engine optimization ? – Amine ES Feb 08 '21 at 06:10

1 Answers1

2

In an answer about as useful as the question,

"No".

Most of us can't read the code because it is packed/obfuscated, and won't invest the time to try to read it.

  • If you're asking if it will prevent the user from opening the Developer Tools, then I don't know, because that would require me trying to run the code, which I'm not going to do, since I can't read the code and it could be malicious.

  • If you're asking if it will prevent someone from obtaining the rest of the code on your website, then no, it will not. A determined user could use curl or one of several other tools to retrieve the raw HTML or Javascript.

  • If you're asking if the code pasted above is secure because it is packed, then no, it is not. A determined user could quite easily analyze the code by hand and, once analyzed, write something to reverse engineer the packed code (that's assuming it uses an unknown packer -- if it uses a well-known packer, then someone has probably already written something to reverse it).

Is there a way to prevent the theft of a website's code?

One can never fully block a determined user from analyzing your code, only make things more annoying from them.

Simply using a minifier/uglifier on Javascript is usually enough to make the code mostly worthless to try to steal, since the cost of trying to analyze, rewrite it and further develop it is usually comparable to the cost of writing the same code from scratch.

Codebling
  • 10,764
  • 2
  • 38
  • 66
  • 1
    Thank you for your replay I saw this code here on stack so that's why I'm asking – Amine ES Feb 08 '21 at 06:12
  • Here is the link on stack https://stackoverflow.com/questions/24319786/how-to-hide-form-code-from-view-code-inspect-element-browser – Amine ES Feb 08 '21 at 06:12
  • 1
    @AmineES Thanks, it's an interesting link. You should have put it in your question to give people more context – Codebling Feb 08 '21 at 06:13
  • @AmineES The correct answer is that you can never fully block a determined user from analyzing your code, only make things more annoying from them. Simply using a minifier/uglifier on Javascript is usually enough to make the code mostly worthless to try to steal, as the cost of trying to analyze, rewrite it and further develop it is usually comparable to the cost of writing the same code from scratch. – Codebling Feb 08 '21 at 06:17
  • 2
    @AmineES you're welcome, and welcome to Stackoverflow! I hope you find it helpful. To get the most out of the site (and generally not make people mad), you might want to read the [Help section](https://stackoverflow.com/help) before you ask your next question. People will generally downvote questions that they don't know *how* to answer (and upvote questions when they don't know *what* the answer is). Hope that helps! Good luck! – Codebling Feb 08 '21 at 06:25