-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtys1.py
21 lines (15 loc) · 1.25 KB
/
tys1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
import base64
# Given RSA parameters
e = 0x10001
n = 0xa8b99ec36a68336cb4fbac235a48d3b8c764ab8f215173d23fa9bcaf6ec11213a8ce08e2806bd40aa0c9daf35e12d78ebb86366475680c60cd125988831b193a1180c8ef70905480f21dad5c2306eb60c73a53c44312f2baf0cf5dd48dcd117287bfaf4ed3890c7adc8136f9b08158e2208d50262bd5d6b1ade2b86362de2021
d = 0xb4cb8764482f3f6d75ae0fd29d352360b40f74a9c1cd0c1dfdc07e7f6d7b95aa4e8d23085d7f7ef42587b51e6829878476b1cbe8434bf5e7528a369b255f727225b6af5ca7072acd027a19ea17d5bd25624a3947fcd956c11a97cc3707e32c2cb75c2aaf30089e3270327a9fb08a9eac83e5466f6ebe1d2ad5125efb71aad9
# Create private RSA key
key = RSA.construct((n, e, d))
# Decryption
ciphertext_b64 = "NLWFPYBfdl28jBYZm9ouVUTVmtpMu+d5VXZnEJqOJv1NYZEDOkZd1N/5y22h6I9vep2GRdaLK3N0BTo6U29zLDtTZHWQyMqCROac6WIp+8tpn13FtjNhNdRZFdF+OINmnrzmPAdnOgErDDnB/XRz3CR1uRNZ8ATV+zjgSqazDn8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
ciphertext_bytes = base64.b64decode(ciphertext_b64)
cipher = PKCS1_OAEP.new(key)
decrypted_message = cipher.decrypt(ciphertext_bytes)
print("Decrypted message:", decrypted_message.decode('utf-8'))