Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been created an interpreter for an scripting engine for my games, and I've created it. But the problem is that I don't want to others to be able to see the code (script), for that, I need to create a compiler that compiles the script to a byte code. But how do you 'design' a byte code? How I do it is try to make it as hard as possible for a human to understand it, while making it easier to interpret it for the interpreter.

What I have tried:

I've designed a byte code that is harder for the user to understand, and is very fast for the interpreter to execute. But the problem is that although a human cannot understand the byte code, a decompiler can be made for the current byte code I have, with a bit of difficult. This is how I my current compiler results:
<br />
QWriteLn('Hello')<br />
<br />
Results in:<br />
<br />
'ex<br />
QWriteLn<br />
's1<br />
Hello<br />
'e1<br />


This is what it means:
<br />
'ex           Execute the function below<br />
QWriteLn      This is the function<br />
's1           it's a string argument to the function which is on line 1<br />
Hello         This is what 's1 is referring to<br />
'e1           This marks the end for the function<br />


As you can see, this byte code can be understood (even if I hadn't explained it). How do I design a byte code that's hard to understand/decompile?
Posted
Updated 3-Mar-16 5:19am
Comments
Dave Kreskowiak 3-Mar-16 11:09am    
No matter what you do, a decomplier will ALWAYS be possible to reverse the byte-code back to something human readable.
Nafees Hassan 3-Mar-16 11:15am    
But how do I make it harder to make a decompiler?
Dave Kreskowiak 3-Mar-16 12:04pm    
Why? Remember, your decoder to run the code is also a decompiler of sorts. So, the harder you make that, the harder you make it on yourself.

1 solution

Don't bother.
If you have a system that works, just encrypt the data, and decrypt it into your program when you need it.
Depending on the language you wrote the game in, encryption in some form is probably built in, or easily available as a library.
The advantage of this is that your strings are also encrypted, and that makes it even harder to understand...
 
Share this answer
 
Comments
Nafees Hassan 3-Mar-16 11:21am    
How come I never thought of that!? Just need to use the algorithm I wrote years ago. :) Thanks!
OriginalGriff 3-Mar-16 11:30am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900