# Secure Programming — How does RSA work and why is it secure?

RSA encryption and decryption process step by step in 10 mins

We all know that RSA is used for encryption. As a serious developer, it’s important to know how does it work and why is it hard to break? In this article, I will walk you through the process of RSA and the Math behind it.

Let’s start.

# Definition

RSA (Rivest–Shamir–Adleman) is a public-key cryptosystem widely used for secure data transmission.

# Prime

RSA is all about playing with Prime numbers. A prime number n means can not be factored by any number between [2, n-1]. e.g. 2,3,5,7,11,13,17,19…

Let’s dive in a little bit deeper.

# Coprime

In mathematics, two integers a and b are coprime, relatively prime, or mutually prime if the only positive integer that is a divisor of both of them is 1. Wiki

So examples 2, and 5 are coprime because they share no common divisor except 1. same for 2 and 7, 3 and 11 ….

# Totient

If ask yourself this question: how many coprime (or relative prime) (x, N), x≤N? This is called the Totient function.

A brute force solution could be looped through every number between [1, N] and check if gcd(x, N) == 1, where gcd is the famous greatest common divisor function, however, which seems to be too slow (for an…

--

--

A channel which focusing on developer growth and self improvement