RSA is an asymmetric cryptosystem.
Cryptosystems are ways to encrypt and decrypt data.
In asymmetric cryptosystems, there is one key for encryption and another key for decryption.
In symmetric cryptosystems, the same key is used for both encryption and decryption.
How does it work?
Start with p and q, which are distinct prime numbers
n = p * q
φ(n) = (p - 1) * (q - 1)
Choose e such that 1 ≤ e < φ(n) and gcd(e, φ(n)) = 1
Find d, where d ≡ e-1 (mod φ(n)), meaning (d * e) % φ(n) === 1
Example: p = 2, q = 17
n = 2 * 17 = 34
φ(n) = (2 - 1) * (17 - 1) = 1 * 16 = 16
Choose e such that 1 ≤ e < φ(n) and gcd(e, φ(n)) = 1,
let’s pick e = 3
Find d, where d ≡ e-1 (mod φ(n)), meaning (d * e) % φ(n) === 1
11 * 3 = 33
33 % 16 = 1
d = 11
The public key is (3, 34). The private key is (11, 34).
Secure Shell (SSH) - used for remote command line interfaces like pushing to GitHub repositories via your local terminal
Transport Layer Security (TLS) - used for secure web browsing (any website that uses https like when you’re doing online banking)
Pretty Good Privacy (PGP) - used for encrypted emails like when Edward Snowden reached out to Laura Poitras to whistleblow about the NSA spying on everyone