コード例 #1
0
from socket import *
import vigenere_cipher


s = socket()        
host = raw_input("Please enter the ip address of the host server computer: ")# ip of host computer windows computer at home is '192.168.2.17'
port = 64922               
s.connect((host, port))


while True:
    message = raw_input("Enter your message: ")
    encrypt_message = vigenere_cipher.encrypt_string(message)
    s.send(encrypt_message)
    
    if message == 'quit':
        break
    
    encrypted_reply = s.recv(1024)
    print "Message recieved: ", encrypted_reply
    reply = vigenere_cipher.decrypt_string(encrypted_reply)
    print "The message is: {0}".format(repr(reply))
    
s.close()
コード例 #2
0
from socket import *
import vigenere_cipher

s = socket()
host = "" # others will connect using the ip adress '192.168.2.11'

port = 64922
s.bind((host, port))

s.listen(5)

c, addr = s.accept()

while True:
  encrypted_data = c.recv(1024)
  print "message recieved: ",encrypted_data
  data = vigenere_cipher.decrypt_string(encrypted_data)
  print "The message is {0}".format(repr(data))
  
  if data == 'quit':
    break

  reply = raw_input("Reply: ")
  encrypted_reply = vigenere_cipher.encrypt_string(reply)
  c.send(encrypted_reply)
  
c.close()