How to protect my functions which will be called by other programmers?

11 views (last 30 days)
I have some Matlab functions stored in my computer. Other people will call those functions from Matlab in their computer. However, I don't want them to see my codes or copy the files of my functions for some reasons. Are there any solutions for this?

Accepted Answer

Image Analyst
Image Analyst on 2 Feb 2019
See this MathWorks link for a full discussion of protecting your source code by deploying as p-code.
  7 Comments
Simon Li
Simon Li on 3 Feb 2019
Thanks. The MATLAB Compiler SDK can create API used by other languages(says C) to access my application in remote server. However, those languages do not include MATLAB. Hence, the client developers who also uses MATLAB as develop environment cannot call the API directly. Since I have too many functions in that API, there will be a lot of work to do. Is there a simple way to do this?
Walter Roberson
Walter Roberson on 3 Feb 2019
You can provide a .h file and a shared object such as a .dll, and have them calllib(), with your shared object making https connection to the remote server. You would have to copy or serialize the data and send it to the remote system.
Or you could provide a series of .m or .p functions that use tcpclient() to make https connection to the remote server. You would have to copy or serialize the data and send it to the remote system.
In theory, DCOM permits remote execution (if I recall correctly), but I suspect that would be a pain to get right and configure on all sides; https://www.cybereason.com/blog/dcom-lateral-movement-techniques

Sign in to comment.

More Answers (1)

Stephen23
Stephen23 on 2 Feb 2019
Two steps:
  1. write your function so that at the start it checks something that only you know about: e.g. your username in the absolute filepath, or the content of a file somewhere. If the check fails, return.
  2. convert to p-code.
Unless they manage to read your mind it is unlikely that they will know what you are checking.

Tags

Community Treasure Hunt

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

Start Hunting!