RSA Algorithm

RSA encryption and decryption algorithm and implementation in C++

RSA is an algorithm used by modern computers to encrypt and decrypt messages. Modern encryption is mostly based on this algorithm.

It is an asymmetric cryptographic algorithm.

Asymmetric means that there are two different keys. This is also called public key cryptography because one of the keys can be given to anyone. The other key must be kept private, Elliptic curve algorithm uses asymmetric cryptography also.

The algorithm is based on the fact that finding the factors of a large composite number is difficult: when the integers are prime numbers, the problem is called prime factorization. It is also a key pair (public and private key) generator.


  1. Choose two different large random prime numbers p and q
  2. Calculate n=pq (n is the modulus used later.
  3. Calculate the totient: \phi(n)=(p-1)(q-1)
  4. Choose an integer e such that 1<e<\phi(n) and e is coprime to \phi(n)
  5. compute d such that de \equiv  1 (mod \phi(n))

Encrypting message

    \[ c=m^e mod\, n\]

Decrypting message

    \[m=c^d mod\, n  \]

Source code link: GitHub repository

Elliptic Curve Algorithm (ECC)

11 thoughts on “RSA Algorithm”

  1. I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.

  2. Heya i’m for the first time here. I found this board and I find It truly useful & it helped me out much.I hope to give something back and aid others likeyou aided me.

  3. A motivating discussion is definitely worth comment. There’s no doubt that that you ought to publish more on this subject, it may not be a taboo subject but usually, people don’t discuss such subjects. To the next! Kind regards!!

  4. It’s difficult to find good quality writing like yours these days. I truly appreciate people like you! Take care!!

  5. Hi! I could have sworn I’ve been to this website before but after browsing through many of the posts I realized it’s new to me. Anyhow, I’m definitely pleased I discovered it and I’ll be bookmarking it and checking back regularly!

  6. You ought to be a part of a contest for one of the most useful websites on the web. I most certainly will recommend this web site!

  7. I simply want to say I’m new to blogging and site-building and actually enjoyed your web blog. Probably I’m want to bookmark your website . You surely come with impressive well written articles. Thanks for revealing your blog.

Leave a Reply

Your email address will not be published. Required fields are marked *