yazdmich

Crypto transfer server

Jun 13th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. from crypto import *
  2. from socket import *
  3. message = ''
  4. seed = int(input('Seed: '))
  5. a = Crypto('key1', message, seed)
  6. s = socket(AF_INET,SOCK_STREAM)
  7. s.bind(('', 20))
  8. s.listen(5)
  9. c,b = s.accept()
  10. print(b)
  11. key = a.key+'\n'
  12. c.send(b'CRYPT_KEY\n '+key.encode()+b'\n ')
  13. message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at vestibulum ante, sed lobortis nisi. Etiam est lacus, euismod at lorem eu, vulputate vehicula nunc.'
  14. message = message.split(' ')
  15. ack = False
  16. n = 0
  17. for word in message:
  18.         a.update(word)
  19.         c.send(a.In().encode())
  20.         n += 1
  21.         print(n)
  22.         resp = b''
  23.         while resp is not b'ACK\n':
  24.                 print('Waiting for client response...')
  25.                 resp = c.recv(4096)
  26.                 continue
  27.  
  28. c.send(b'FIN\n')
  29. c.close()
  30. s.close()
Advertisement
Add Comment
Please, Sign In to add comment