I often see people asking about protecting their SWF files after they’ve created their game. Of course they’re invited to use a encoder, but that’s generally not enough. This article will show you some ways to dissuade the hacker from doing his work. Feel free to leave your comments and questions below or on the MochiAds forum thread.

It’s always frustrating when we work for months and then some guy takes our work and calls it his own. Of course there are ways to pursue them after this happens, but here are some ways to stop them or make it harder. With this tutorial, you will learn some methods to easily protect your games, without using complex math or programs. It’s all ActionScript using variables. So let’s begin:

Encrypt Your SWF

First, get a program to encrypt your SWF file. This is important because it will stop most hackers. I recommend Amayeta SWF Encrypt. The trial version allows 25 encryptions, so use it wisely before buying, because the full version costs $125 USD. Note that Amayeta and similar programs don’t protect your game 100%, but they do make it more difficult for folks to steal. There’s also Flash Encryption Genius, which also offers a free trial — with the full license costing $99 USD. I tried those two and here is my review:

  • SWF Encrypt: The most well-known of the encryption tools offers different levels of security. However, because it’s popular, more hackers are focused on ways to bypass it. Another downside is that the trial version leaves a big watermark on the top left corner (see screenshot 1, below). A plus is that you can preview the game directly in the program. It’s useful when there are many files. We can also selectively choose what to encrypt.
  • Flash Genius: This program allows you to choose parameters for protection (Main Scene, Button Event, etc.) just like SWF Encrypt, and the game works perfectly. However, it prints a small watermark almost in the middle of the screen, which can make playing hard (see screenshot 2, below). It works for Windows, Mac OS X and Linux.
  • 1.

    2.

    Make Your Code Harder To Read

    Next, I’ll explain some ways to make the decompiler work harder to further protect your code.

    After you’ve made your game, the first thing to do is select “Find and Replace,” and replace all your variables’ name with something of no relation.

    For example, instead of the variable “Lives_remaining,” use “Pie_is_my_device.” Be mindful in creating these words; keep a text document for yourself that tracks what each variable name means — so you know what to change if you need to. Doing this makes it harder for a hacker to decompile your code. Instead of finding neatly organized variables that he can change and modify, he will have to spend energy trying to figure out what each variable means.

    Protect From Import

    Flash provides the ability to import compiled Flash files, which allows a Flash SWF file to be imported into an FLA. If you check the “protect from import” box in Flash, you can protect your file from being imported into a Flash file by another user.

    Instructions: In Flash, navigate to “File,” and then “Publish Settings.” On the “Flash” tab, select the “Protect from Import” box and enter a password.

    I’ve Been Hacked, What Do I Do?

    If your game was seriously decompiled, what do you do? If it’s a sponsored game, I would recommend alerting your sponsor and enlisting their help with dealing with the Flash site. It’s also a good idea to contact the website you’ve seen your game on via email or through their contact form to request that they remove the game. In some cases, they may not be aware that the game was illegally copied. Send them a polite and professional message to request taking it down. Good luck!

    I hope you found these tips useful. Don’t forget that there is always a way to bypass protection. The tips I mentioned can make it more difficult, but make sure you use these in addition to your other encryption methods.