public_key_cryptography course - challenges 5 - decryption

This commit is contained in:
boyreau 2026-11-05 13:06:33 +01:00
commit 15131cf4fa
2 changed files with 8 additions and 0 deletions

View file

@ -16,3 +16,9 @@ def Euler_totient(p: int, q: int) -> int:
# Challenge PK-crypto-4
def private_key(p: int, q: int, exp: int) -> int:
return pow(exp, -1, (p - 1) * (q - 1))
# Challenge PK-crypto-5
def decode(p: int, q: int, exp: int, c: int):
pk = private_key(p, q, exp)
return pow(c, pk, p * q)