<RSA> Cryptography Simulator

Interactive Asymmetric Encryption Engine

Configuration Workpad

1. Prime Selection

Select two prime numbers. In reality, these would be 2048-bit numbers. We use small primes for visibility.

2. Core Parameters

Calculate the modulus and totient.

3. Key Generation

Must be coprimeCoprime
Two numbers are coprime if their Greatest Common Divisor (GCD) is exactly 1. They share no common prime factors.
to φ. Typically 65537.

The Modular InverseModular Multiplicative Inverse
Finds a number 'd' such that (d × e) remainder φ = 1. Found using the Extended Euclidean Algorithm.
of e mod φ.

4. Encryption Input

Input an integer M where 0 ≤ M < n.

Factoring Complexity

Time to derive keys grows exponentially with Bit Length.

Time (Years) n Bit-Length

Live Encryption Stream

Public Key

Shared with everyone.

{ e: -, n: - }

Private Key

Kept strictly secret.

{ d: -, n: - }

Compute: C = M^e mod n Alice
- = -- mod -
Output: Ciphertext (C) Network
---

Vulnerability Scanner

Real-time analysis of cryptographic weaknesses in the current RSA configuration.

Eth-Root Attack

If the public exponent e is very small (like 3) and the message M is short, M^e might not wrap around the modulus n.

// TARGET PARAMETERS
e = -
M = -
n = -
Step-by-Step Mathematical Crack:
1. Observe C = Me mod n
2. If Me < n, then C = Me (No wrap occurred)
3. Therefore, M = e√C
> -
Python
import gmpy2

# Intercepted from network stream
C = None
e = None

# When e is small (e.g., 3) and padding is missing
def eth_root_crack(ciphertext, exponent):
    # gmpy2.iroot calculates the precise integer root
    m, exact = gmpy2.iroot(ciphertext, exponent)
    if exact:
        return m    # Original Plaintext!
    return None

# Execute Hack
plaintext = eth_root_crack(C, e)
print(f"Cracked Message: {plaintext}")
Awaiting Parameter Lock ...

Fermat Factorization

Exploits the RSA modulus n if the chosen primes p and q are mathematically too close.

Step-by-Step Mathematical Crack:
1. Let N = p × q (where p, q are close)
2. We can express N = x² - y² = (x - y)(x + y)
3. Start guessing x = ⌈√N⌉
4. Calculate y² = x² - N
5. Loop: Increment x until y² is a perfect square
6. Found them! p = x - y, q = x + y
Python
import math

# Requires no keys, only the public Modulus
def fermat_crack(n):
    a = math.ceil(math.sqrt(n))
    b2 = a*a - n
    # Loop until b2 is a perfect square
    while not math.isqrt(b2)**2 == b2:
        a += 1
        b2 = a*a - n
    b = math.isqrt(b2)
    return (a - b, a + b) # Returns p & q!
Waiting for modulus lock...