def decrypt(c): return rsa.gmpy2.powmod(rsa.mpz(c), rsa.mpz(d), rsa.mpz(n))
def encrypt(m): return rsa.gmpy2.powmod(rsa.mpz(m), rsa.mpz(e), rsa.mpz(n))
def read_n(): global n f = open(sys.argv[1], 'r') n = f.read() f.close() def read_d(): global d f = open(sys.argv[2], 'r') d = f.read() f.close() if not check_args(): sys.exit("usage: python3 rsa_encrypt.py N PRIVATE_KEY CIPHERTEXT") read_n() read_d() f = open(sys.argv[3], 'r') length = int(f.readline()) output = str() for i in range(0, length): c = rsa.mpz(f.readline()) output += str(chr(char_code(decrypt(c)))) print(output)