8
\$\begingroup\$

HTML5 games have viewable source code. Is there a way to make them like swf file?

How to hide the game algorithm?

What do you think of the Firefox JavaScript Deobfuscator Plugin and obfuscation?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ If you tell us the reason that you want to obfuscate, we can give you a much better answer, possible (probably), show you that you don't actually need to hide your code. \$\endgroup\$
    – jcora
    Commented Jul 16, 2012 at 20:04
  • 3
    \$\begingroup\$ Also a SWF file isn't protected either.. you can easily decompile and extract all assets and code from it. There are obfuscators out there, but they aren't stopping something who's really determined. \$\endgroup\$
    – bummzack
    Commented Jul 16, 2012 at 20:06
  • \$\begingroup\$ How much time you need to fully restore swf application after decompiling? \$\endgroup\$
    – Rustam
    Commented Jul 17, 2012 at 7:41
  • \$\begingroup\$ Also, why would you want to? \$\endgroup\$
    – brice
    Commented Sep 13, 2012 at 14:44

8 Answers 8

10
\$\begingroup\$

If you want to protect your source, don't write it in HTML/Javascript?

Part of the really nice things about the web as it's all human-readable. This makes it an excellent learning resource. If you're telling me that you've never looked at the source of a website to learn how it does something, then feel free to tell me I'm wrong.

I'm all bout sharing the love with code, otherwise I wouldn't answer questions on a website about offering help, all for free, would I?

Edit: I've said what I think of it, is there a way to make it non-readable? No, not in pure JS/HTML. The reason for this is simple: Somewhere down the line, it becomes readable. If you obfuscate it then a deobfuscator gets you. If you use a cipher or translate it somehow, at some point you have to translate it back into javascript (and the code to translate it back needs to be in your source too!).

The best you can do is to protect against bandwidth theft and obfuscate if you really feel the need, but it's not going to stop people if they're really determined.

\$\endgroup\$
5
  • 6
    \$\begingroup\$ flash and java can be decompiled, binaries can be disassembled, javascript can be deobfuscated. Your source is not protected just because you didn't write it in javascript. \$\endgroup\$
    – Esailija
    Commented Jul 16, 2012 at 20:07
  • 2
    \$\begingroup\$ @Esailija the average effort it takes is not the same, except you are a trained reverse engineer/security expert/hacker/waht so ever. \$\endgroup\$ Commented Jul 16, 2012 at 21:59
  • 3
    \$\begingroup\$ Just a quote from anywhere: "What a man do any other man can undo." and I add to it: "With the right intent and will, nothing is really protected." \$\endgroup\$ Commented Jul 17, 2012 at 12:41
  • \$\begingroup\$ well i wouldnt call it a really nice thing; more of a "blessing and a curse" situation \$\endgroup\$
    – CobaltHex
    Commented Jul 17, 2012 at 22:13
  • \$\begingroup\$ I would call it its 'base mechanic': it's really easy to steal on the web. This is why we have the speed and complexity of innovation we do. Newton, Picasso, Eliot and I'm sure more have all coined maxims around direct theft, even if nobly justified by the shoulders of giants. Shakespeare was excellent at theft. \$\endgroup\$
    – Matt Kemp
    Commented Jul 17, 2012 at 22:21
5
\$\begingroup\$

You can put a lot of it on the server via Node.js and just return back results of functions. but other than that it's like Matt Kemp says. The code that runs is readable by a human, it's impossible to hide it.

\$\endgroup\$
2
\$\begingroup\$

Even if you don't obfuscate your code, HTML/ JS is already about the same level of difficulty to reverse engineer as SWF.

SWF files contain the original Actionscript code, (IIRC), with comments etc, unless they're obfuscated. Names of objects etc, are also contained within the SWF.

SWF decompilers / recompilers exist, and just because you can't see it with a text editor, does not mean SWF is in any way safe from reverse engineering.

In fact the level of obfuscation is really no different to a SWF. You could obfuscate your JS code using some obfuscator, but that just makes bug reports more difficult to interpret.

You probably want to focus your efforts into making something worth stealing, rather than preventing people stealing it. Plenty of SWFs get ripped off and used for unauthorised purposes (with changed graphics, etc)

\$\endgroup\$
2
\$\begingroup\$

Use the free Yahoo YUI compressor.

I use it because it compresses my code drastically (including removing comments and unnecessary whitespace). This lets me comment and structure my code exactly how I want without worrying about how easy I'm making it for thieves.

Additionally if you want to read the Javascript for a complex site after all variable and function names have been essentially destroyed -- well, good luck with that. It's much harder to figure out what code is doing when you have no hints.

(Though with YUI compressor you may need to augment its functionality to also get rid of function names. I have altered the way I name functions specifically for the purpose of automatically and selectively removing most function names. This may require some custom code on your end.)

\$\endgroup\$
1
\$\begingroup\$

No, and there is really no reason to! If you want to sell your work, you can do that without obfuscation. People pay for content, not code. Sell your artwork, story, music, etc., and give away the code freely (it already is, anyway).

\$\endgroup\$
1
\$\begingroup\$

HTML5 games have viewable source code. Is there a way to make them like swf files?

Yeah, use Flash and translate your code to ActionScript.

How would one go about hiding the game algorithms?

In absolute terms, you can't do that.

What do you think of the Firefox JavaScript Deobfuscator Plugin and obfuscation?

Obfuscation is nothing but a very thin barrier for somebody who'd be serious about stealing your code. Still, it's simple to setup, it can repulse the most dumb script kiddies, and it's the only thing you can do to protect client-side code. It has the additional benefit that it reduces the script size (faster download) and can even optimize the code (faster execution). Check this entry on Stack Overflow for details on obfuscation. Summary: you have plenty of options. I personally tried UglifyJS and had very satisfactory results.

\$\endgroup\$
0
\$\begingroup\$

As we all know HTML5 relies on JavaScript as a programming language. In theory all tools that protect JavaScript should work on HTML5.

The only tool I know that currently supports HTML5 in the context of Gaming development is JScrambler. I'm not sure if others will work.

For the porpoise of discussion, obfuscation is not a silver bullet. We have software that is compiled encrypted, protected with several anti copy solutions and still o can get them without paying. That said I believe that obfuscation beats leaving your code open for any one to read when you intention is not that.

I really love open source and support the movement yet sometimes closing the source makes lots of sense.

\$\endgroup\$
0
\$\begingroup\$

You can use native code. Programming on C++ and compile for HTML5. Cocos2d-X is a library that work on iOS, Android, and HTML5. Your code will be hidden.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .