fork download
  1. # Values from the challenge
  2. n = 1079
  3. e = 43
  4. p = 13 # Smaller prime
  5. q = 83 # Larger prime
  6. c_list = [996, 894, 379, 631, 894, 82, 379, 852, 631, 677, 677, 194, 893]
  7.  
  8. # Step 1: Calculate Phi(n)
  9. phi = (p - 1) * (q - 1)
  10.  
  11. # Step 2: Calculate the private key 'd'
  12. # Using pow() with -1 calculates the modular multiplicative inverse
  13. d = pow(e, -1, phi)
  14.  
  15. # Step 3: Decrypt each character
  16. plaintext = ""
  17. for c in c_list:
  18. m = pow(c, d, n)
  19. plaintext += chr(m)
  20.  
  21. print(f"Private Key (d): {d}")
  22. print(f"Decrypted Message: {plaintext}")
  23.  
Success #stdin #stdout 0.1s 14172KB
stdin
Standard input is empty
stdout
Private Key (d): 595
Decrypted Message: SKY-KRYG-5530