MATLAB and FreeMat
Information Page
bookCover
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 is FreeMat?

FreeMat is a free software program that emulates MATLAB input/output for much of the latter's functionality. Octave is another such MATLAB clone that has been around a bit longer, but FreeMat is easier to install, set paths (when you write programs), and it has a built-in editor for writing programs. Programs written for FreeMat should be compatible to run on MATLAB, and vice-a-versa, "most of the time." When problems occur, it is usually because 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 FreeMat, which has versions for PC, Mac, Linux platforms: FreeMat Download page . From this page, you can also download an extensive user's manual.

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

Not much at all. Once you have MATLAB (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 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 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 either of 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 FreeMat programs?

Most of the programs have been written to work on both platforms. however, since, as mentioned above, FreeMat does 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 FreeMat programs. In cases where it was necessary to change the MATLAB program, the corresponding 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, 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.

How can I learn more about MATLAB?

For people who are new to computer programming, the single most important constructs are logical loops. The downloadable document: Introduction to For and While Loops in MATLAB  document contains the basics of for and while loops in MATLAB. The following segments of my book Introduction to MATLAB with Numerical Preliminaries , published by John Wiley & Sons (2005)
Contents(pdf)
will prepare you to understand and write programs similar to these cryptography programs:

     Chapter 1, Section 3.1, Chapter 4, Section 7.1.

NOTE: This book is essentially identical to the first seven chapters of the author's larger book Introduction to Introduction to Numerical Ordinary and Partial Differential Equations Using MATLAB
Contents(pdf)