- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How is RSA Algorithm Calculated?

RSA is a cryptosystem for public-key encryption, and it is broadly used for securing sensitive information, specifically when being sent over an insecure network including the Internet.

RSA algorithm is the most popular asymmetric key cryptographic algorithm depends on the mathematical fact that it is simply to discover and multiply large prime numbers but complex to factor their product. It needs both private and public key.

### Example of RSA Algorithm

Let us take an example of this procedure to learn the concepts. For ease of reading, it can write the example values along with the algorithm steps.

Choose two large prime numbers P and Q

Let P = 47, Q = 17

Calculate N = P x Q

We have, N = 7 x 17 = 119.

Choose the public key (i.e., the encryption key) E such that it is not an element of (P -1) x (Q – 1)

Let us find (7 - 1) x (17 -1) = 6 x 16 = 96

The factors of 96 are 2, 2, 2, 2, 2, and 3 (because 96 = 2 x 2 x 2 x 2 x 2 x 3).

Therefore, it can select E such that none of the factors of E is 2 and 3. We cannot choose E as 4 (because it has 2 as a factor), 15 (because it has 3 as a factor) and 6 (because it has 2 and 3 both as factors).

Let us choose E as 5 (it can have been any other number that does not its factors as 2 and 3).

Choose the private key (i.e., the decryption key) D including the following equation is true:

(D x E) mod (P – 1) x (Q – 1) = 1

Let us substitute the values of E, P, and Q in the equation.

We have (D x 5) mod (7 – 1) x (17 – 1) = 1.

That is, (D x 5) mod (6) x (16) = 1.

That is, (D x 5) mod (96) = 1

After some calculations, let us take D = 77. Then the following is true: (77 x 5) mod (96) = 385 mod 96 = 1 which is what we wanted.

For encryption, calculate the cipher text (CT) from the plain text (PT) as follows:

CT = PT

^{E}mod NLet us assume that we want to encrypt plain text 10. Then, we have

CT = 10

^{5}mod 119 = 100000 mod 119 = 40.Send CT as the cipher text to the receiver.

Send 40 as the cipher text to the receiver.

For decryption, calculate the plain text (PT) from the cipher text (CT) as follows:

PT = CT

^{D}mod NIt perform the following:

PT = CT

^{D}mod NThat is,

PT = 40

^{77}mod 119 = 10, which was the original plaintext of step5.

- Related Articles
- What is the RSA Algorithm in Information Security?
- C++ Program to Implement the RSA Algorithm
- What are the applications of RSA Algorithm?
- What are risks in implementing the RSA algorithm without padding?
- What are the steps of key generation using RSA algorithm?
- How does RSA work?
- How value of firm is calculated
- How is the cost of debt calculated?
- How is Current Asset Turnover Ratio Calculated?
- What is abnormal return and how is it calculated?
- How is the expected return on a portfolio calculated?
- How is the Cost of Equity calculated using CAPM?
- How terminal cash flows are calculated
- How are equity cash flows calculated?
- What is Terminal Value of a new business and how is it calculated?