* This encryption is made entirely according to mathematical calculations.
* We will see in a moment how functions and modular arithmetic in particular are used for this encryption.
* This encryption type which was used at various times in the past, is also the basic of today's encryption.
* Curriculum topics related to Affine Cipher/ Aim : Linear functions, modular arithmetic, prime numbers, composite numbers, between prime numbers,divisibility, common divisors
EXAMPLE
ENCRYPTION
Encryption is done according to a linear function
f(x)=ax+b (mod m)
* m is the number of letters in the alphabet used.
* a and b constans are the keys to the cipher.
* x is the number represented by the letter in plain text.
* f (x) is the value that creates the encrypted text.
* mod is moduler arithmetic.
For example, let's convert the plain text "AFFINE CIPHER" in to ciphertext according to the key (a, b) = (5,8). Let's give numbers to letters, starting from 0 first.
PlainAlphabet | 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 |
CipherAlphabet | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
Now, we will find the value of the A,F,I,N,C,P,H,E,R letters according to
f(x)=5x+8 (mod 26) function.
For example we can make for "N"
N=13
f(13)=5.13+8=73
73=21 (mod 26), (The remainder from the division of 73 with 26 is 21)
f(13)=21 (mod 26)
21= V
So, the letter N in plain text corresponds to the letter V in cipher text. If the values corresponding to the other letters are found one by one, the following table is obtained.
Plaintext | A | F | F | I | N | E | C | I | P | H | E | R | |
x | 0 | 5 | 5 | 8 | 13 | 4 | 2 | 8 | 15 | 7 | 4 | 17 | |
5x+8 | 8 | 33 | 33 | 48 | 73 | 28 | 18 | 48 | 83 | 43 | 28 | 93 | |
5x+8 (mod 26) | 8 | 7 | 7 | 22 | 21 | 2 | 18 | 22 | 5 | 17 | 2 | 15 | |
Ciphertext | I | H | H | W | V | C | S | W | F | R | C | P |
Then you can find ciphertext IHHWVC SWFRCP.
Method: Affine cipher, Key=(5,8), Plaintext=AFFINE CIPHER, Ciphertext= IHHWVC SWFRCP.
DECRYPTION
If we want to decrypt the ciphertext "IHHWVC SWFRCP"
We have to do the reverse transaction. f (x), inverse of the function
f-1 (x) = (x-8) / 5
We need to find the equivalent of this function in mod 26 . To remove the denominator, we need to expand the fraction by a number to make the denominator 1 in mod 26. This number is 21.
f-1 (x) = 21. (x-8) / 21.5
= 21 (x-5) / 105
= 21 (x-8) /1
= 21 (x-8)
f-1 (x) = 21 (x-8), (mod 26)
So we will use is this function for decryption. Let's decrypt IHHWVC SWFRCP with this function.
For example, we can do for letter "C"
C=2
f-1 (x) = 21 (x-8)
f-1 (2) = 21 (2-8)
= - 126
To find the equivalent of -126 in (mod 26) we need to add a multiple of 26.
-126 + 5.26 = -126 + 130 = + 4 = E
So, the letter C in cipher text corresponds to the letter E in plain text . If the values corresponding to the other letters are found one by one, the following table is obtained.
Plaintext | I | H | H | W | V | C | S | W | F | R | C | P | |
x | 8 | 7 | 7 | 22 | 21 | 2 | 18 | 22 | 5 | 17 | 2 | 15 | |
21(x-8) | 0 | -21 | -21 | 294 | 273 | -126 | 210 | 294 | -63 | 189 | -126 | 147 | |
21(x-8) (mod 26) | 0 | 5 | 5 | 8 | 13 | 4 | 2 | 8 | 15 | 7 | 4 | 17 | |
Ciphertext | A | F | F | I | N | E | C | I | P | H | E | R |
No comments:
Post a Comment