Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Keyword Cipher

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Keyword Cipher

A keyword cipher is basically a form of monoalphabetic substitution. A keyword is used


to determine the letter mapping from plain to ciphertext. First, the repeated letters in the
keyword are removed, then the cipher alphabet is generated. For generating cipher
alphabet keyword is matched with A, B, C etc., until all the letters of the keywords are
used up after which the standard alphabetical letters are used in order, excluding those
which are already in the key.

Encryption:
The first line of input contains the keyword which you wish to enter. The second line of
input contains the string which you have to encrypt.
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
Encrypted: K R Y P T O S A B C D E F G H I J L M N Q U V W X Z
With KRYPTOS as the keyword, all As become Ks, all Bs becoming Rs, and so on.
Encrypting the message “knowledge is power” using the keyword “Kryptos”:
Encrypting the message: Knowledge is Power
Encoded message: IlmWjbaEb GQ NmWbp

Example2

Input :
Keyword : secret
Message : Zombie Here
Output :
Ciphered String : ZLJEFT DTOT
Take the first example, we used "secret" keyword there.
Plain Text : 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
When "secret" keyword is used, the new encrypting text becomes :
Encrypting : S E C R T A B D F G H I J K L M N O P Q U V W X Y Z
This means 'A' means 'S', 'B' means 'E' and 'C' means 'C' and so on.
Lets encode the given message "Zombie Here"
ZOMBIE HERE becomes ZLJEFT DTO
Introduction

Keyword Cipher is another method of encrypting alphabetic text. It is a type of


monoalphabetic substitution cipher. Monoalphabetic means an alphabet in
plain text is mapped to one alphabet in the ciphertext. For example, if the plain
text contains multiple occurrences of ‘A’ then all occurrences of ‘A’ are
substituted by the same alphabet in the ciphertext.

Encryption

Suppose the plain text is

“HELLO WORLD”
Next, we have to choose a keyword. The keyword should not have any
repeated alphabets. Let the keyword be

“DRAGON”
Next, we map each alphabet in plain text to the alphabet in the ciphertext. The
starting N alphabets of plain text are mapped to the alphabet of the keyword
where N is the length of the keyword.

To fill the rest of the alphabets in the ciphertext, we use the remaining
alphabets in chronological order. We skip over those alphabets that are
already present in the ciphertext. See the figure shown below

We use the above mapping to encrypt the plain text.

Plain Text: “HELLO WORLD”


Keyword: “DRAGON”
Cipher Text: “COIIL WLQIG”
Decryption

Decryption is very simple. We map plaintext alphabets to ciphertext alphabets


using the keyword then use the reverse mapping to convert the ciphertext to
plaintext

You might also like