A substitution cipher is an encryption algorithm which works by replacing plaintext units with corresponding ciphertext units, following some rule depending on the key.

The term substitution cipher is mostly used for historical ciphers, in contrast to transposition ciphers. Substitution ciphers working on a small alphabet (i.e. small units, like characters or pairs of characters) are susceptible to statistical attacks, and should not be used.

Modern block ciphers (when used in ECB mode) are in principle substitution ciphers whose units are the blocks. These effectively have an alphabet size of 2block-size.