source code hiding.
9 views (last 30 days)
Show older comments
hi. I would like to know how i can hide the source codes i have written so that nobody can access them? even a professional user! Thanks.
0 Comments
Answers (2)
Jan
on 28 Nov 2011
P-coding prevents the user from reading the source. But the function can still be accessed in the meaning of executed by Matlab. Do you want to forbid the execution also? Then encrypt the files.
A professional user can use the debugger to run through the P-coded function line by line abd inspect all changes in variables. Even local variables can be changed on-the-fly and all used functions can be shadowed. Therefore a password protection like this has a very limited security level:
function Match = CheckPassword(In)
Password = '1234asdf';
Match = strcmp(In, Password);
end
P-coding conceals the source. But if you create a file called "strcmp.m" in the same folder, the password can be displayed easily:
function T = strcmp(A, B)
disp(A);
disp(B);
T = true;
end
But you can avoid calling toolbox functions for critical sections:
function Match = CheckPassword(In)
switch In
case '1234asdf'
Match = 1;
otherwise
Match = 0;
end
end
But such construction are usually too strange and limited for a very small set of commands. E.g. I did not use true and false to avoid the possibility for overloading them...
I think, the Matlab Compiler is the best method to conceal the contents of M-files. But even here you cannot be 100% secure and if your program is expensive enough, a professional will be able to find out, what's going on.
0 Comments
See Also
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!