The following example clearly demonstrates the RSA encryption algorithm:

Encrypt and decrypt the message "CAB" by the RSA algorithm. For simplicity, take small numbers - this will reduce our calculations.

* Выберем p=3 and q=11. * Определим n= 3*11=33. * Hайдем (p-1)*(q-1)=20. Следовательно, d будет равно, например, 3: (d=3). * Выберем число е по следующей формуле: (e*3) mod 20=1. Значит е будет равно, например, 7: (e=7). * Представим шифруемое сообщение как последовательность чисел в диапозоне от 0 до 32 (незабывайте, что кончается на n-1). Буква А =1, В=2, С=3. 

Now encrypt the message using the public key {7.33}

 C1 = (3^7) mod 33 = 2187 mod 33 = 9; C2 = (1^7) mod 33 = 1 mod 33 = 1; C3 = (2^7) mod 33 = 128 mod 33 = 29; 

Now decrypt the data using the private key {3.33}.

 M1=(9^3) mod 33 =729 mod 33 = 3(С); M2=(1^3) mod 33 =1 mod 33 = 1(А); M3=(29^3) mod 33 = 24389 mod 33 = 2(В); 

Here I am interested in this moment:

Choose a number e by the following formula: (e 3) mod 20 = 1. We define the number e for which the following relation is true (e d) mod ((p-1) * (q-1)) = 1.

How is this number chosen? At random? Or, nevertheless, can we somehow bring in mind е= ?

    1 answer 1

    mod - modulo comparison in mathematics and the remainder of the division in programming.

    As far as I understand, e must be one of the numbers that is greater than 1 and less than (p-1)*(q-1) (not inclusive). Then it should be with the function (p-1)*(q-1) mutually simple . Those. NOT selected from the bald.

    • I will try to formulate the question in a simple way: (e*3) mod 20=1 . How will you search for him? - Gorets
    • Well, you can think of the algorithm for finding mutually-simple numbers to a certain number (just google it). Here e is the public key. So you can choose as e a random number if there are more than one co-prime numbers to (p-1)*(q-1) . - Anton Mukhin
    • 2
      e = (20 * x + 1) / 3; x - any integer - Ilmirus
    • And do not forget that (p-1)*(q-1) , with p != q ; p,q — prime; - is an indicator of the number of prime numbers less than n (pq = n) - Dex