0

There's a bit of code I want to encrypt from users when they use view page source or in inspect element so I want to obfuscate it. (The code is a Javascript)

The one that starts with:

eval( function( p, a, c, k, e, d ) ...

But when I try to put that code in a single post page in the html tab, it shows nothing in the preview tab. Why is that? Or sometimes it shows the code itself.

amarinediary
  • 4,930
  • 4
  • 27
  • 45
  • Does this answer your question? [How to hide or secure javascript code from client side](https://stackoverflow.com/questions/5167853/how-to-hide-or-secure-javascript-code-from-client-side) – amarinediary Jan 04 '21 at 18:36

2 Answers2

1

You can't hide or encrypt nor obfuscate js but you can use a javascript minifier.

Minification refers to the process of removing unnecessary or redundant data without affecting how the resource is processed by the browser - e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so on.

You can use https://www.minifier.org/ to minify on the go.

This minifier removes whitespace, strips comments, combines files, and optimizes/shortens a few common programming patterns.

amarinediary
  • 4,930
  • 4
  • 27
  • 45
  • Then why when I inpect some website I see this code that starts with eval(function(p,a,c,k,e,d)... when I deobfuscate it turn out to be a normal JS. – user3279936 Jan 04 '21 at 19:45
0

Ok I did a queck search on google and this come out.

Make sure to look at the options and see how it should be obfuscated

Alen.Toma
  • 4,684
  • 2
  • 14
  • 31
  • This is just a fancy minifier. Who does the opposite of minifying. It's just converting to ASCII characters. – amarinediary Jan 05 '21 at 00:45
  • I think, it is what he needs. So with a little tweaking he could get `eval(function(p,a,c,k,e,d)` That he want. the site you refer to is too simple for his need. And all minifier is more or less obfuscate dont you think :) its just simple count on how advanced the tool is. – Alen.Toma Jan 05 '21 at 00:48
  • I agree. But at the end of the day, you can't really hide your code. It's not an intended behaviour, and it shouldn't be encouraged. – amarinediary Jan 05 '21 at 00:50
  • Oh Why is that, its just your opinion. If i develop a tool and want people to buy should I make it simpler for them to use for free. All my hard work etc. I develop some library and I did make them with MIT License but that dose not make it the only right way. Well its as i said, its optional – Alen.Toma Jan 05 '21 at 00:55
  • Sure it's an opinion. But for protecting your intellectual property you have patent, legal defences... etc. In any case, let's not debate. this is just a comment section =D – amarinediary Jan 05 '21 at 00:58