Пример #1
0
	crypt = Homophonic()
	
elif(dataSplit[0] == "d"):
	crypt = Polygram()

#Begin receiving file, decrypting, and logging
f = file("messages.txt","w+")

while(True):
	data = cli.recv(BUFSIZE) #Receive the message from server
	if(str(data) == ""):
		continue
	if(data == "bac.,!? "): #Checks for end of messages, if so break out of while
		break

	#f.write(data+"\n")
	data = str(data)
	number = data[0:2]
	data = data[2:] #Strip order number from string. Discard it for now?
	s = crypt.decrypt(data) #Decrypt the message
	
	#Strip spaces from end of message in case of polygram
	if(dataSplit[0] == "d"):
		s.strip()	

	#Write decrypted message to log.txt
	f.write(str(number)+". "+s + "\n")

cli.close()
f.close()