Substitution Cipher encoder and decoder

A simple pair of functions to encode messages and decode them by means of frequency analysis.

You are now following this Submission

This function uses frequency analysis to attack and decode messages
encoded using a /substitution cipher/ which exchanges each letter of the
alphabet for another. Unlike the famous "Caesar Shift" cipher, which
"shifts" the letters of the alphabet along by a certain amount, giving
just 26 possible ciphers, this has no specific order, giving 26!
possibilities. The function is very unlikely to work first time but,
depending of the length of the text, highly likely to get the letters "T"
and "E" correct. From here the user may spot an error in the decoding,
such as "TQE" which is obviously "THE", and the function offers them the
chance to swap the offending letters as often as is required. After a few
simple cases, the encrypted message is generally broken.
It removes all punctuation and case from the original
text. The other m-file can be used to encode messages in the substitution cipher, using a random arrangement of letters and giving the user the cipher key as well as encoded message.

Cite As

Dafydd Stephenson (2026). Substitution Cipher encoder and decoder (https://www.mathworks.com/matlabcentral/fileexchange/31522-substitution-cipher-encoder-and-decoder), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0