Obscuring Matlab code for sharing

“Security through obscurity” alone does not actually confer security. Obscuring code simply increases effort for someone who wishes to use code for unauthorized purposes. For Matlab “.m” code, two methods to partially obscure the underlying “.m” code for locally-run Matlab-based algorithms are:

  • compile Matlab code to executable (OS-specific and Matlab version-specific)
  • convert Matlab code to pcode (OS-agnostic and Matlab version-agnostic)

In general, when critical IP needs to be made available for user data while keeping IP non-public, this is done by providing web services. For example, the IP of Google, Bing, Office 365 is usable via web services, but generally the core code remains non-public.

Matlab pcode() can obscure directories or lists of files to “.p” code that runs on Matlab on any supported OS. Newer versions of Matlab use a more powerful obscuration algorithm that is not backward compatible.