AFFINE CIPHER

767 2 0
                                    

AFFINE CIPHER
>>The affine is a type of monoalphabetic substitution cipher, where each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter.

AFFINE CIPHER>>The affine is a type of monoalphabetic substitution cipher, where each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

In the affine cipher the letters of an alphabet of size m are first mapped to the integers in the range 0 … m − 1. It then uses modular arithmetic to transform the integer that each plaintext letter corresponds to into another integer that correspond to a ciphertext letter. The encryption function for a single letter is

where modulus m is the size of the alphabet and a and b are the keys of the cipher

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.


where modulus m is the size of the alphabet and a and b are the keys of the cipher. The value a must be chosen such that a and m are coprime. The decryption function is

where a−1 is the modular multiplicative inverse of a modulo m

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

where a−1 is the modular multiplicative inverse of a modulo m. I.e., it satisfies the equation

The multiplicative inverse of a only exists if a and m are coprime

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

The multiplicative inverse of a only exists if a and m are coprime. Hence without the restriction on a, decryption might not be possible. It can be shown as follows that decryption function is the inverse of the encryption function,

 It can be shown as follows that decryption function is the inverse of the encryption function,

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

EXAMPLE:

In these two examples, one encrypting and one decrypting, the alphabet is going to be the letters A through Z, and will have the corresponding values found in the following table.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
012345678910111213141516171819202122232425

Encrypting

In this encrypting example, the plaintext to be encrypted is "AFFINE CIPHER" using the table mentioned above for the numeric values of each letter, taking a to be 5, b to be 8, and m to be 26 since there are 26 characters in the alphabet being used. Only the value of a has a restriction since it has to be coprime with 26. The possible values that a could be are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. The value for b can be arbitrary as long as a does not equal 1 since this is the shift of the cipher. Thus, the encryption function for this example will be y = E(x) = (5x + 8) mod 26. The first step in encrypting the message is to write the numeric values of each letter.

 The first step in encrypting the message is to write the numeric values of each letter

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.


Now, take each value of x, and solve the first part of the equation, (5x + 8). After finding the value of (5x + 8) for each character, take the remainder when dividing the result of (5x + 8) by 26. The following table shows the first four steps of the encrypting process.

The final step in encrypting the message is to look up each numeric value in the table for the corresponding letters

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

The final step in encrypting the message is to look up each numeric value in the table for the corresponding letters. In this example, the encrypted text would be IHHWVCSWFRCP. The table below shows the completed table for encrypting a message in the Affine cipher.

 The table below shows the completed table for encrypting a message in the Affine cipher

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.



Codes and Ciphers Where stories live. Discover now