Your teacher gave you:
Public key: (10142789312725007.5)
which means
n = 10142789312725007 e = 5
where n is the module and e is the public indicator.
In addition, you are provided
Private key: (10142789312725007, 8114231289041741)
means that
d = 8114231289041741
where d is the decryption rate, which should remain secret.
You can "break" the RSA by knowing how to determine the "n" in its "p" and "q" simple factors:
n = p * q
The easiest way is probably to check all the odd numbers starting just below the square root of n:
Floor[Sqrt[10142789312725007]] = 100711415
You will get the first factor in 4 attempts:
10142789312725007 mod 100711415 = 100711367 10142789312725007 mod 100711413 = 100711373 10142789312725007 mod 100711411 = 100711387 10142789312725007 mod 100711409 = 0 <-- Winner since it evenly divides n
So we have
p = 100711409
Now,
q = n / p = 10142789312725007 / 100711409 = 100711423
Why is it important? This is because d is a special number such that
d = e^-1 mod phi(n) = e^-1 mod (p-1)*(q-1)
We can check it out.
d * e = 40571156445208705 = 1 mod 10142789111302176
This is important because if you have text message m , then ciphertext
c = m^e mod n
and you will decrypt it with
m = c^d = (m^e)^d = (m^(e*d)) = (m^(e*e^-1)) = m^1 (mod n)
For example, I can โencryptโ message 123456789 using your teacherโs public key:
m = 123456789
This will give me the following ciphertext:
c = m^e mod n = 123456789^5 mod 10142789312725007 = 7487844069764171
(Note that "e" in practice should be much larger, because for small values โโof "m" you do not even exceed n)
Anyway, now we have "c" and can cancel it with "d"
m = c^d mod n = 7487844069764171^8114231289041741 mod 10142789312725007 = 123456789
Obviously, you cannot calculate "7487844069764171 ^ 8114231289041741" directly, because it has 128,808,202,574,088,302 digits, so you should use the modular exponentiality trick.
In the "real world" n is obviously much more. If you want to see a real-world example of how HTTPS uses RSA under covers with 617-digit n and e from 65537, see my blog post โ The first few milliseconds of an HTTPS connection .