RSA-2048 Encryption Explained

Introduction
Last week the cryptography world had a scare. Unverified claims circulated that RSA-2048 — the public-key algorithm that still protects a huge amount of web traffic, email, and software signatures — might have been broken. Germany’s Federal Office for Information Security (BSI) said its experts were reviewing those claims, and the story spread quickly through the tech press.
As of this week, there is no public evidence that it happened. Nature reported that as of December 1, 2026, there was no indication RSA encryption had been broken. What did come out, on November 30, was a separate, theoretical result from Anthropic against certain structured-lattice post-quantum schemes — not RSA. Researchers have been quick to say that result is not a practical break of anything currently deployed.
Even so, the episode is a useful reminder. RSA is still the quiet workhorse of a lot of internet security, and the longer-term question — what happens when a large quantum computer can run Shor’s algorithm — has not gone away. I thought this was a good moment to walk through how RSA-2048 actually works, in plain English, with the math and a couple of Python examples.
The padlock analogy
RSA is a public-key, or asymmetric, cryptosystem. That means the key you use to lock a message is not the same as the key you use to unlock it.
A useful picture is a padlock. I can manufacture a pile of open padlocks and hand them out to anyone. Those open padlocks are my public key. You put a message in a box, snap one of my padlocks shut, and send me the box. Anyone can lock it. Only I have the physical key that opens the padlock — that is my private key — so only I can read what you sent.
In RSA terms:
- The public key is a pair
(n, e). Anyone can use it to encrypt. - The private key includes
d(and, in practice, the secret primes used to buildn). Only the owner should ever have it, and only it can decrypt.
The clever part is that I can publish the padlock without giving away the key. The reason that works is a math problem that is easy to do in one direction and extremely hard to reverse.
Why factoring is the hard problem
Start with two large prime numbers, p and q. Multiplying them is easy:
n = p * q
The result, n, is the modulus. It is part of the public key, so anyone can see it. Recovering p and q from n alone is the integer factorization problem. For small numbers this is trivial. For the size of primes used in RSA-2048, there is no known practical method on a classical computer.
That hardness is the foundation. If an attacker can factor n, they can reconstruct the private key and read (or forge) whatever that key was meant to protect. If they cannot factor n, the padlock stays shut.
Generating a key pair
Here is the actual key-generation recipe, stripped down to the essential steps.
- Choose two random primes,
pandq. - Compute the modulus:
n = p * q. - Compute Euler’s totient:
phi(n) = (p - 1) * (q - 1). This value is secret, because it is built frompandq. - Choose a public exponent
e. In almost every real system this is65537. It needs to be coprime tophi(n)so that a modular inverse exists. - Compute the private exponent
das the inverse ofemodulophi(n):d = e^-1 mod phi(n). In Python that is justpow(e, -1, phi).
The public key is (n, e). The private key is d (along with n, and usually p and q as well, which let implementations decrypt faster).
Why 65537? It is a Fermat prime (2^16 + 1), it is large enough to avoid some attacks that work against tiny exponents such as 3, and it has only two bits set, which makes the public-key operation — raising a message to the power e — relatively fast.
Encryption and decryption
Treat the message as an integer m that is smaller than n. Then:
- Encrypt with the public key:
c = m^e mod n - Decrypt with the private key:
m = c^d mod n
That is the whole core of textbook RSA. The reason decryption works is number theory: because d is the inverse of e modulo phi(n), Euler’s theorem gives you m back.
As we will see later, nobody should use those two formulas by themselves on a real message. The math is right; the raw scheme is not safe. But it is the right place to start, and a tiny example makes it concrete.
A tiny Python demo (not for real use)
The primes below are toys. A 2048-bit modulus is hundreds of digits long. These two are two digits each, which means a laptop can factor n instantly. This is only here to show the moving parts.
# Educational only — NOT for real use.
# These primes are tiny on purpose and provide no security.
p = 61
q = 53
n = p * q # 3233
phi = (p - 1) * (q - 1) # 3120
e = 65537
d = pow(e, -1, phi) # 2753
message = 42 # must be an integer < n
ciphertext = pow(message, e, n) # 2557
plaintext = pow(ciphertext, d, n) # 42
print(n, phi, e, d)
print(ciphertext, plaintext)
Running that prints:
3233 3120 65537 2753
2557 42
So 42 encrypts to 2557 and decrypts back to 42. Notice that we can use the real-world public exponent 65537 even with this toy modulus. It works because 65537 and phi are still coprime; in fact 65537 is just 17 modulo 3120, which is why a textbook often uses e = 17 for this same example.
Two things this demo cannot do: it cannot protect anything, and it cannot even hold a normal string. The integer value of a short word is already larger than n = 3233. Real RSA needs a much larger modulus, and it needs padding, which is what the next example uses.
The real-world version: RSA-2048 with OAEP
In production you do not pick primes by hand, and you do not encrypt raw integers with pow. The Python cryptography library will generate a 2048-bit key and encrypt with OAEP, which is the padding scheme you want for RSA encryption. OAEP uses a mask generation function (MGF1) and a hash — SHA-256 in the example below — to turn the textbook formula into something that is safe to use on short messages.
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
)
public_key = private_key.public_key()
message = b"Hello from RSA-2048"
ciphertext = public_key.encrypt(
message,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None,
),
)
plaintext = private_key.decrypt(
ciphertext,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None,
),
)
print(private_key.key_size) # 2048
print(plaintext) # b'Hello from RSA-2048'
I ran this as written. It generated a 2048-bit key with e = 65537, produced a 256-byte ciphertext, and decrypted back to the original message. The ciphertext itself will be different every time you run it. That is a feature of OAEP: the padding is randomized, so encrypting the same message twice does not give an attacker a deterministic fingerprint.
Practical points
Why 2048 bits? The “2048” is the size of n in bits — a number with about 617 decimal digits, made from two primes of roughly 1024 bits each. That size is widely treated as the current baseline. It corresponds to about 112 bits of classical security. RSA-1024 is no longer considered adequate. RSA-3072 (about 128-bit security) and RSA-4096 are used when you want more margin, or when a standard or a customer asks for it.
NIST’s current final guidance in SP 800-131A still treats 2048-bit RSA as acceptable. Its October 2026 report on the post-quantum transition, IR 8547, lays out the longer path: quantum-vulnerable public-key cryptography is planned to be deprecated after 2030 and disallowed under NIST standards and guidelines after 2035. Federal high-value and high-impact systems are on an even earlier clock. Bigger RSA keys buy you more classical margin; they do not solve the quantum problem.
Padding is mandatory. Textbook RSA — just c = m^e mod n — is insecure. It is deterministic, it is malleable, and small or structured messages leak. OAEP exists to prevent those attacks. If you are signing rather than encrypting, the modern choice is PSS, not a raw signature and not PKCS#1 v1.5 if you can avoid it. If a library offers a “raw” or “textbook” RSA mode, do not use it.
Hybrid encryption with AES. RSA is the wrong tool for encrypting a file, a database row, or a long message. A 2048-bit key with OAEP and SHA-256 can only wrap about 190 bytes. The usual design is hybrid encryption: generate a random AES key, encrypt the real data with AES-GCM (or another authenticated symmetric cipher), and use RSA only to encrypt that AES key. TLS and most “encrypt this with their public key” features you meet in the wild are doing some version of that. RSA wraps the key; AES carries the payload.
The quantum threat, and what comes next. A sufficiently large, fault-tolerant quantum computer running Shor’s algorithm could factor n and recover the private key. That machine does not exist today, and last week’s rumor cycle did not change that. What is already a practical concern is harvest-now-decrypt-later: an attacker can record ciphertext today and wait until a future quantum computer, or some other breakthrough, makes it readable. Data that needs to stay secret for many years should not be betting on RSA remaining hard forever.
That is why the industry is moving toward post-quantum algorithms. NIST has already standardized ML-KEM (FIPS 203, the Kyber design) for key encapsulation and ML-DSA (FIPS 204, the Dilithium design) for signatures. They are meant to run on the computers we have now, and to resist both classical attacks and Shor’s algorithm. The Anthropic result from last week is a reminder that post-quantum crypto is still an active research area, and that migration plans may need to keep up as the analysis improves. The destination, though, is still post-quantum cryptography — not “stay on RSA forever.”
Closing thought
Last week’s scare was a reminder, not an obituary. RSA-2048 still holds against the computers we actually have, and there is still no public evidence that it has been broken. But a lot of the internet’s trust still rests on the difficulty of factoring one large number, and that is not a foundation we should expect to last indefinitely.
If you understand the padlock, the primes, and why padding and hybrid encryption exist, you are in a much better place to decide where 2048-bit RSA is still fine, where a larger key is worth it, and where you should already be planning a move to ML-KEM, ML-DSA, or a hybrid of classical and post-quantum schemes.