A general substitution cipher has possible keys, but its key is a whole scrambled alphabet, which is hard to remember and hard to share. One way to make the key easier to remember is to build the scrambled alphabet from a keyword.
A keyword substitution scheme will greatly cut down on the possible number of mappings between plaintext and ciphertext letters, but it has the benefit of being much easier to remember. Start by choosing a word or phrase. We’ll use science math for our keyword. Remove any spaces and then remove any repeated letters, leaving us with scienmath, and use this reduced keyword to start the mapping between plaintext and ciphertext letters:
plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z
ciphertext: S C I E N M A T HTo finish out the mapping, go from A to Z in order, skipping over any already used letters:
plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z
ciphertext: S C I E N M A T H B D F G J K L O P Q R U V W X Y ZYou can probably see that this does a pretty good job mapping letters near the keyword, but not near the end of the alphabet, where in this example u through z in the plaintext are mapped to the same letters in the ciphertext. One way around this is to use longer keywords that contain a variety of letters, including those at the end of the alphabet.
keyword: quick brown fox jumped over the lazy dog
plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z
ciphertext: Q U I C K B R O W N F X J M P E D V T H L A Z Y G SAnother way around this is to use a secondary piece of information, a keyletter, to offset where you place the keyword.
Keyletters¶
Suppose we chose a keyletter of g to go with the keyword/keyphrase of science math. We would begin the same way, reducing the keyword down to scienmath. However, instead of placing this reduced keyword at the start of the cipher alphabet, we would place it underneath the position indicated by the keyletter of g.
plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z
ciphertext: S C I E N M A T HThen, we carry on as normal placing the unused letters of the alphabet in order after the keyword. When we reach the position underneath z in the plaintext alphabet, we wrap back around to a. This has the benefit of ensuring that the letters at the end of the alphabet don’t always get mapped to themselves.
plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z
ciphertext: U V W X Y Z S C I E N M A T H B D F G J K L O P Q R