필터 지우기
필터 지우기

hiding 1) content of .mat file and 2) .m file names as well as the content

조회 수: 10 (최근 30일)
paul ki
paul ki 2011년 11월 27일
답변: David Leffingwell 2023년 6월 12일
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

채택된 답변

Jan
Jan 2011년 11월 27일
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.
  댓글 수: 1
paul ki
paul ki 2011년 11월 28일
Thank you both for the answers.
I have about 50 files from different tools I wrote and some others like LIBSVM which need to be in this package.
As i wrote, in addition to content, I need to hide also the matlab file names (otherwise I need to rename them all such as fun1...fun50 which is a big headache).
So, is there a way to compile it all in a format but use it from matlab as a regular matlab function, without need to run it from a command line?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 27일
I don't know if you will be able to hide the file names with any provided mechanism.
pcode can obscure .m file contents. There are ways that a sufficiently dedicated person can dig information (but not complete source) out of pcode'd files.
If you use the MATLAB Compiler, then deploytool will create AES encrypted files that are decrypted on-the-fly . However, auxilary files such as .mat files are, as best I recall, unpacked to plain-binary files.
MATLAB does not provide any mechanisms for load() to work in binary streams (such as a pipe that reads and decrypts a file.)
If you are concerned about protecting .mat files, you should consider using fwrite() to save the variables as binary files. You could apply encryption when you do that; your program would then have to read and decrypt the values from the binary files.

David Leffingwell
David Leffingwell 2023년 6월 12일
If you have access to the MATLAB Compiler, you can it to create a standalone application. Use the -s option to obfuscate the file and folder structure inside the standalone application (which is a self-extracting Zip file). The -s option also encrypts your data (e.g. MAT files) and mex files in addition to your M files. Also you can use the -j option to automatically P-Code all your M files. See here for more details.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by