import base64 import libnum from Crypto.PublicKey import RSA
pubkey_str = """-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCK/qv5P8ixWjoFI2rzF62tm6sDFnRsKsGhVSCuxQIxuehMWQLmv6TPxyTQPefIKufzfUFaca/YHkIVIC19ohmE5X738TtxGbOgiGef4bvd9sU6M42k8vMlCPJp1woDFDOFoBQpr4YzH4ZTR6Ps+HP8VEIJMG5uiLQOLxdKdxi41QIDAQAB -----END PUBLIC KEY----- """
# Decryption function defdecrypt(cipher_text): cipher_text = base64.b64decode(dec_replace(cipher_text)) plain_text = b"" for i inrange(0, len(cipher_text), 128): part = cipher_text[i:i+128] dec = libnum.n2s(pow(libnum.s2n(part), pubkey.e, pubkey.n)) plain_text += dec return plain_text
# Main execution if __name__ == '__main__': pubkey = RSA.import_key(pubkey_str) c = "Encrypted Data Here" decrypted_message = decrypt(c) print(f"Decrypted data: {decrypted_message}")