2

I need to write a program in either Python or MATLAB that contains some proprietary information, but will not easily reveal this proprietary information if the program is distributed.

While I realize that a determined hacker can reverse engineer any source code, would it be easier to secure code written in Python or MATLAB?

  • Not in python. You can distribute the "compiled" .pyc files instead of the `.py` files... but that's python bytecode and can pretty easily be unraveled. – mgilson May 09 '13 at 15:00
  • Is it data or your implementation that you are trying to protect? – James May 09 '13 at 15:55
  • I am trying to protect the implementation, specifically some equations. There isn't any data written into the program. – user2366657 May 12 '13 at 14:00

2 Answers2

4

In MATLAB you can use the command pcode, which preparses your MATLAB code to a form that is unreadable by humans, but runs exactly the same (actually, very slightly faster) as the original MATLAB code. What happens is that for each .m file you pcode, you'll get a new file with a .p extension. The .p file runs the same as the .m file, but is unreadable.

Alternatively, you can purchase MATLAB Compiler, which will convert your entire application into a standalone executable where the code is encrypted.

Eitan T
  • 32,660
  • 14
  • 72
  • 109
Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
  • 3
    +1: Just nitpicking: the code in the standalone executable is not encrypted, it's machine code. Theoretically speaking, it can be reverse engineered. – Eitan T May 09 '13 at 15:08
  • The documentation for `pcode` is a little confusing. Sometimes it states it *encrypts*, and sometimes *content-obscures*. If it is encrypted, the presumably you must also provide some method to decrypt at run time for legitimate users. – James May 09 '13 at 16:08
  • 1
    @EitanT No, that's not true. MATLAB Compiler produces a thin executable wrapper which, true, is machine code. But all this wrapper does is to start up the MCR and then execute your MATLAB code against it. The MATLAB code is packaged with the thin excutable wrapper and possibly the MCR, and is _encrypted_, not machine code. It's encrypted with AES. – Sam Roberts May 09 '13 at 16:46
  • @SamRoberts Huh, I've double-checked the [MathWorks documentation](http://www.mathworks.com/desktop-web-deployment/deploying-code-executable-software-component.html) again, and it seems that you're right. I stand corrected! – Eitan T May 09 '13 at 16:50
1

It seems to be pretty easy to do in MATLAB:

pcode <filename>

See the Documentation Center.

For python see the Python wiki.