document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import socket
  2. from rsa_operations import *
  3. from sys import argv
  4. from random import randint
  5. import time
  6.  
  7. rsa_math = RSAMath()
  8. host, port = argv[1], argv[2]
  9.  
  10.  
  11. s = socket.socket()
  12. s.connect(("127.0.0.1", int(port)))
  13.  
  14. print "Enter your password:"
  15. m = int(raw_input())
  16. s.send("%s connected."%host)
  17. e, n = 0, 0
  18. while True:
  19.   rec = s.recv(1024)
  20.   if rec == "e":
  21.     e = int(s.recv(1024))
  22.     print "Received e: %s"%e
  23.   if rec == "n":
  24.     n = int(s.recv(1024))
  25.     print "Received n: %s"%n
  26.  
  27.   if e != 0 and n != 0:
  28.     print "Original m: %s"%m
  29.     c = rsa_math.exp(m, e) % n
  30.     print "Ciphertext: %s"%c
  31.     s.send("c")
  32.     s.send(str(c))
  33.  
  34. s.close()
');