How Encryption and Decryption process computer do by mathematics

Today I'm gonna talk about how computers actually encrypt data and also decrypt data. There are a lot of encryption and decryption algorithm are there but for our learning purposes we will talk about the easy one which is Affine code function

let's start

Step 1: To encrypt data you need a function like that:

f(x) = Px + K "P" will be a natural odd number and "K" will be an integer

Suppose we have data "GERMANY" and you have to encrypt it also decrypt it from another site

Firstly we have converted this to the Alphabetic number

A = 0 B = 1 C = 2 ....... ....... Z = 25 in similer way

" G | E | R | M | A | N | Y " 6 | 4 | 17 | 12 | 0 | 13 | 24

Step 2:

After complete, your 1st step you have to make one function for your algorithm For this example, I'm making this function f(x) = 5x + 10

each of the digits you have to pass throw this function f(6) = 56 + 10 = 40 f(4) = 54 + 10 = 30 f(17) = 517 + 10 = 95 f(12) = 512 + 10 = 70 ............. ............. ............. f(25) = 5*25 + 10 = 130

after making this function you get another value of the number

" G | E | R | M | A | N | Y "

6   | 4  | 17 | 12  | 0  | 13 |  24

40 | 30 | 95 | 70 | 10 | 75 | 130 =(function make this digit)

Step 3: Do MOD Operation of those numbers

Note Mod operation bassicaly reminder of the division 12 | 22 | 1

       12

        10 (reminder)

So we can say MOD(22,10) = 10 (ans)

Hope you get this

So now we got the numbers and we have to do MOD operaion on those things note: mod operation will done 26 cause alphatic total number is 26 MOD(40,26) = 14 MOD(30,26) = 30 MOD(95,26) = 17 .............. .............. .............. MOD(130,26) = 0

Now We get new set of numberic value

14 | 4 | 17 | 18 | 10 | 23 | 0

If we do same process step 1 make this number to the alphabatic order

O | E | R | S | K | X | A

So, now you can see GERMANY become encrypted and change the data and make this OERSKXA

Now how can we decryted this code from other computer OERSKXA

Step 1: " O | E | R | S | K | X | A" 14 | 4 | 17 | 18 | 10 | 23 | 0

Step 2: Minus 10 First cause our function has 5x+10 this is the reason we have to minus 10 form alphabatic numaric value

14-10  4-10  7-10  18-10  10-10  23-10  0-10

So now number become

4 -6 7 8 0 13 -10

Step 2: Now there is negtive value so add +26 to the negetive value

4 (26 - 6) 7 8 0 13 (26-10) final value

4 20 7 8 0 13 16

Step 3 : Note: if number is below 26 MOD not necessarty but if number get more then 26 thats time we need to do MOD operation on those number

Step 4: we have to know about multiplier

m = (26 * n + 1) / P n = natural number p = function Odd number

if n = 1; m = (261 + 1) / 5 = 5.4 (Not take this) n = 2 m = (262 + 1) / 5 = 10.6 (Not take this) n = 3 m = (263 + 1) / 5 = 15.8 (Not take this) n = 4 m = (264 + 1) / 5 = 21 (take this)

Which number has interger value you have to take this otherwise just increse the value of = "n"

Step 5: Now multiply the number into 21

421 2021 721 821 021 1921 16*21

Now the final value of this

84 420 147 168 0 273 336

there is value more then 26 so we have do mod operaion again

MOD(84,26) = 6 MOD(420,26) = 4 .................... ....................

6 4 17 12 0 13 24 if we convert this number to the alphbatic way that is 6 = G 4 = E 17 = R 12 = M 0 = A 13 = N 24 = Y G E R M A N Y (depcrepted)

in this way emcription and decription works

`