Every time you shop online, your credit card number travels across the internet — through dozens of routers, many of which you don't control. Anyone intercepting that data stream would see the credit card number in plain text, unless the data is encrypted. Today's encryption is so strong that even with every computer on Earth working together, breaking it would take longer than the age of the universe. This extraordinary security doesn't come from complex machinery — it comes from a mathematical trick involving numbers so large that certain operations become one-way streets.

The One-Way Function

The foundation of modern cryptography is the one-way function: a mathematical operation that's easy to compute forward but practically impossible to reverse. Multiplying two large prime numbers together is easy — a computer does it in microseconds. But given a large number, finding which two primes were multiplied together (factoring) is extraordinarily hard. A 2,048-bit number (about 620 digits) can be multiplied in milliseconds, but factored in longer than the sun's remaining lifetime with known algorithms.

Easy: 61 × 53 = 3,233 Hard: 3,233 = ? × ? (factoring — have to find 61 and 53) For 2048-bit numbers: Multiplication: microseconds Factoring: estimated 10²⁵ years with best known algorithms

This asymmetry — easy one way, impossible the other — is the mathematical bedrock of RSA encryption, used for most secure internet communication.

RSA: Public Key Cryptography

RSA is clever because it solves a seemingly impossible problem: how can two people communicate secretly when anyone can listen to everything they say — including the initial exchange of keys? The answer is public key cryptography. Each person has two keys: a public key (shared openly, even with adversaries) and a private key (kept secret). A message encrypted with the public key can only be decrypted with the private key.

RSA Key Generation: 1. Choose two large primes p and q (keep secret) 2. Compute n = p × q (public — the modulus) 3. Choose public exponent e (typically 65537) 4. Compute private exponent d such that e × d ≡ 1 (mod φ(n)) where φ(n) = (p-1)(q-1) Encryption (anyone can do): ciphertext = message^e mod n Decryption (only private key holder): message = ciphertext^d mod n Security: finding d requires knowing p and q, which requires factoring n.

The "mod n" operation means divide by n and keep the remainder — like clock arithmetic. The security rests entirely on the hardness of factoring n. Even though n is public, recovering p and q from it is computationally infeasible for large enough n.

When You Visit a Website

When your browser connects to a bank's website (https://), here's what happens. Your browser receives the bank's public key. Your browser generates a random session key, encrypts it with the bank's public key, and sends it. Only the bank's server — holding the private key — can decrypt this session key. Now both your browser and the bank share a secret session key that was never transmitted in the clear. All subsequent communication is encrypted with this symmetric key. The entire handshake takes milliseconds and is mathematically secure against interception.

Modular Arithmetic: The Clock Math Behind It All

Modular arithmetic is the mathematical system underlying RSA. "37 mod 12 = 1" means: 37 divided by 12 leaves remainder 1 — the same as 1 o'clock on a 12-hour clock. This system has the crucial property that exponentiation is easy to compute (using repeated squaring) but discrete logarithms — finding what exponent produces a given result — are hard. This hardness of certain modular arithmetic problems is the mathematical guarantee that RSA's encryption is secure.

Other Cryptographic Applications

The same mathematical principles protect digital signatures (proving a document came from who it claims), blockchain transactions (each Bitcoin transfer is cryptographically signed), and password storage (passwords are stored as one-way hashes, not in plain text). Elliptic curve cryptography — a more efficient alternative to RSA using a different one-way function — is now standard on smartphones, providing the same security with shorter keys.

Conclusion

Modern cryptography is built on mathematical asymmetry: operations that are easy in one direction and practically impossible to reverse. Multiplying primes is easy; factoring their product is not. This asymmetry enables RSA encryption, which lets two parties establish a secret communication channel even when adversaries can see everything exchanged. The mathematics of modular arithmetic — clock arithmetic scaled to numbers with hundreds of digits — is what makes your credit card number safe on the internet. The strongest lock in the world is made of pure mathematics.