-1

I want to use exec to execute python code (using the byte code, instead of the raw text that python will interpret). It's all for a competition where you can see the code of the other competitors, I want to be able to hide my code well enough so people won't bother messing with my code.

How do I do that?

  • 1
    What do you mean "messing with my code"? If the competition is open (i.e. everyone's code is shared with everyone else) why do you want to obfuscate yours? Have you read e.g. stackoverflow.com/q/3344115/3001761, stackoverflow.com/q/576963/3001761, stackoverflow.com/q/261638/3001761? – jonrsharpe Feb 4 '15 at 10:34
  • 3
    But why not? Even if it's not explicitly against the rules, it sounds like you would be gaining an unfair advantage by obfuscating your code when other people's code is visible. Also, frankly, what makes you think that your code is so amazing that the other competitors would need to steal it? – jonrsharpe Feb 4 '15 at 10:57
  • 1
    @jonrsharpe It's a competition where you create bots, I'm now on the lead and I don't want anyone to steal my algorithm. I would like to obfuscate my code to try and prevent it. – Zach P Feb 4 '15 at 11:57
  • 1
    @user3195614 If someone steals your algorithm it'll be plainly visible to others. If they improve on it, good for them, because surely you could've done the same by looking at other people's entries too. – Doval Feb 4 '15 at 13:18
  • 2
    @user3195614: when in this specific competition everyone can see everyone else's code, isn't that intended by the competition makers? What do the contest rules say about that? Are you sure you are not risking a disqualification when you obfuscate your code? – Doc Brown Feb 4 '15 at 13:25
3

That's most likely not going to work. Even if you provide them with byte code only, it's usually possible to simply deassemble the code.

You'll lose comments, formatting and possibly variable names that way though. Code obfuscation might be an option, but at the same time you're not really hiding anything (which in the end is impossible, even if someone has to interpret machine code instructions in the end).

  • I don't mind comments and variable names and all of these, I have the original code, I just want to hand in the encoded for people to see. I know they can disassemble, but I would like to start it this way, the disassembling stage would probably bother a couple of competitors so they won't do it. So do you have any general idea ? I'll look for code obfuscation for now – Zach P Feb 4 '15 at 9:46
  • To amplify this answer, there is no language nor executable which will prevent other sufficiently motivated opponents from gleaning your algorithm. As a corollary, you're not as clever nor unique as you assume. If I am incorrect, file a patent and don't participate in the competition. – msw Feb 4 '15 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.