MATLAB, Octave, and FreeMat
Information Page
relating to the programs that accompany the book:
Introduction to Cryptography with mathematical Foundations and Computer Implementations,
by Alexander Stanoyevitch
Chapman & Hall/CRC Press (August 2010)

To get to the main cryptography page, click the following link: Stanoyevitch's Main Cryptography Page.

What is MATLAB?

MATLAB is a powerful computing platform that is extensively used in numerous scientific disciplines in industry, government, and academia. Its programming language is very intuitive, and is similar to those of the C-family. It is much more than a good programming platform, however, due to the numerous built-in mathematical functions, its particular strength in matrix and array manipulations, and state-of-art graphics capabilities. MATLAB is a proprietary software that can be purchased (for nearly all computing platforms) through MathWorks. Student versions can be purchased at significant savings for current students; the price is about $100.

What are Octave and FreeMat?

Octave and FreeMat are free software programs that were designed to emulate MATLAB input/output for much of the latter's functionality. Octave has been around longer but it was not until 2015 when a gui verion was created. FreeMat was created as a gui. Programs written for Octave or FreeMat should be compatible to run on MATLAB, and vice-a-versa, "most of the time." When problems occur, it is usually because Octave or FreeMat does not have a certain built-in MATLAB function that is in your program.

The following link takes you to a download page for Octave, which has versions for PC, Mac, Linux platforms: Octave Downloadpage .

The following link takes you to a download page for FreeMat, which has versions for PC, Mac, Linux platforms: FreeMat Download Page . From this page, you can also download an extensive user's manual.

WARNING: One important difference between Octave and FreeMat is that the latter is not so well maintained anymore. A check in 2015 shows a 2 year backlog on FreeMat's support group's dealing with bug reports and posting updated versions. As newer operating systems develop, certain updates and fixes are necessary to make sure they run correctly. I have encountered some serious issues with FreeMat while trying to run it on newer Windows 7 PCs (but it still works fine on older Windows 7 PCs and some other operating systems). So my advice is that if you try FreeMat and it has problems running on your machine, just switch to Octave. Octave seems to have a long standing and active support group. Hopefully some new qualified people will join the FreeMat support group to help fix and maintain it once again. Both are wonderful resources.

How much MATLAB do I need to know to use these cryptography MATLAB programs?

Not much at all. Once you have MATLAB (or Octave or FreeMat) installed, you will need to download and place the programs in a directory of your computer and then use MATLAB's path tool to add this directory to MATLAB's path. (The path includes all directories where MATLAB searches for programs when you try to run a program on the command window. Since some of the programs call on (depend on) others, it is safest to download all of the programs and place them in the same directory. Rather than downloading the programs one-by-one, two links on the main cryptography page allow you to download a zip file for all MATLAB programs or all Octave/FreeMat programs. Once you have downloaded, (unzipped,) and placed the programs in a specific directory on your computer, here is how to set the path to include the directory. For the purposes of illustration, let's assume the directory is called StanoyevitchCrypt in your C-drive:

Setting the path in MATLAB (for ver 7.*, at least): On the "FILE" menu, select the option "Path Tool" and a new "Set Path" window will pop up. On this window, click on the button "Add with Subfolders...". A new "Browse For Folder" window will pop up. On this window, navigate to the C folder and click on the folder "StanoyevitchCrypt," and then click on the "OK" button. Finally click on the "Save" button on the previous window, and close the window.

Setting the path in Octave: At present (the initial gui version of) Octave does not have a menu button on its window for setting the path (but surely this will change in the near future). Here is how to do it using the command window (a method that should always work in the future): First, navigate to the desired directory in the "File Browser" field near the top of Octave's window by clicking on the gear icon to its right. For illustration purposes on a PC box, let's say this directory is: C:/Users/Alex/Documents/StanoyevitchCrypt Highlight and copy this name. Next, in the command window enter the command path(" then paste the above copied file name, then close of the parentheses "). The full command that you enter should look like this:

addpath("C:/Users/Alex/Documents/StanoyevitchCrypt") to

To check that your path has been updated, just enter the command path and check to see that your newly added directory appears in the list.
Finally enter the command savepath() so that this path will be saved for all future sessions.

Setting the path in FreeMat (for ver 4.*, at least): On the "TOOLS" menu, select the option "Set Path..." and a new "Set Path" window will pop up. On this window, navigate to the folder "StanoyevitchCrypt," click on the button "Add With Subfolders," then click on the "Save" button on the previous window and close the window. Next, quit the FreeMat Program (either by selecting the "Quit" option from the "FILE" menu, or simply clicking on the "X" button in the upper right corner of the FreeMat window), and restart the program.

Note: In any the above path setting procedures, the "Save" option ensures that this process need not be repeated in future uses of the program (unless you create new subfolders in the directory structure). However, if you are using a laboratory machine (for which you do not have administrator priviledges), this path setting procedure needs to be repeated each time you start the program. Instructors of courses in cryptography might wish to arrange with their lab administrator to add the StanoyevitchCrypt as a permanent directory and to save the path settings.

Once you have downloaded the programs and set the path as above, you are ready to use them. To use any particular program, you simply need to enter its name and input in the command window (the main interface window that opens when you start MATLAB or FreeMat). The command window in MATLAB typically uses ">>" as the prompt (or "EDU>>" for the Student Version). The prompt in FreeMat looks like "-->". The crypt program sample input/output page  can be used to see exactly what needs to be entered in the command window. More details about the program functionality and the algorithms behind them can be found in the book.

Is there any difference between the Crypt MATLAB and Octave/FreeMat programs?

Most of the programs have been written to work on both platforms. however, since, as mentioned above, Octave and FreeMat do not have all of the built-in functions that MATLAB has, it was occasionally necessary to modify the MATLAB program (slightly), or to add an auxilliary program so that a specific program could work with FreeMat. Such auxilliary files have been included in the downloadable complete directory of Octave/FreeMat programs. In cases where it was necessary to change the MATLAB program, the corresponding Octave/FreeMat program was given the same name with a "_FM" suffix. In the document crypt program sample input/output page , all examples list the FreeMat commands and program names. So any program name with the "_FM" suffix should have this suffix removed when working with MATLAB (and the corresponding set of MATLAB programs).

Can these programs help me to write similar programs in another programming language?

Yes, absolutely: The language of MATLAB is very intuitive and could almost serve as a pseudocode. Also, many of the programs have helpful comments (following the "%" symbol) that are ignored by MATLAB and are there to help readers understand the structure of the program. The computer implementation material at the end of each chapter gives more detailed and platform-independent developments on how such programs can be written.

Are there any other good MATLAB clones that are free?

Yes, there is a third well-known free MATLAB clone, called Scilab . Like FreeMat and Octave, it is also a gui. FreeMat and Octave originated in USA, while Scilab came about in France and it seems to be quite popular in France, in particular. Once I get some time for it, I hope to eventually check the functionality of all of the programs of my cryptography suite and make any needed modifications so they will all run on Scilab. I would certainly be grateful to anyone who is interested in both cryptography and Scilab and would like to undertake this project and be willing to share the results.