Obscuring Matlab code for sharing

Security through obscurity is a technique that used 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 sharing 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

Matlab pcode() can obscure directories or lists of files to “.p” code that runs on Matlab ≥ R2007b on any supported OS. Based on webpages (some of which have been taken down via Mathworks DMCA) and forum discussions, the pcode algorithm (pre-R2007b and post-R2007b) are claimed to be broken, with offers to decrypt pcode out there. This activity probably breaks Matlab IP restrictions and may even run afoul of the law.