MATLAB: Hiding 1) content of .mat file and 2) .m file names as well as the content

hiding codehiding data fileshiding file namesMATLAB

Hi there, I need to send a software, containing about 50 files including .m, compiled mex, and .mat, to be used by someone who will test it in matlab. I need to hide: 1) content of .m files, 2) content of .mat files (I load during the run of my .m files), 3) the file names
What is the proper way to do it?
I believe pcode is not quite appropriate, and mcc is not quite right for?
Thank you in advance, Paul Ki

Best Answer

You cannot hide the contents securely, if you want the user to run your program. Even if you encrypt the MAT files, you need a function to decrypt them and then the values are found in clear text in the memory, from where they can be copied by a debugger.
P-coding the M-files is sufficiently secure, if the costs of the software are less than 10$ per line.
You can read the MAT files and convert it to M-code, e.g. by FEX: generate-m-file-code-for-any-matlab-variable . Then you can P-code the results.
Compiled MEX files are a kind of encrypted already. It is not trivial to use a reverse-engineering to get the contents of the files.
I suggest to look how others solve the problem of shipping a program for testing: E.g. MathWorks delivers new releases of Matlab for beta-testing. All testers must confirm a non-disclosure agreement. This is more efficient than encrypting the files.
Related Question