I'm a highschool student with a passion for Python, and this is my first try at networking.
server.py
import select
import socket
import sys
import time
from encrypt import AESCipher
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setblocking(0)
server_addr = ('localhost',46643)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(server_addr)
passwd = input('You can now enter a password for your server, or press enter for none: ')
enc = AESCipher(passwd)
server.listen(12)
SOCKS = [server]
nicknames = {}
def chat_server():
  global SOCKS, nicknames, passwd
  while SOCKS:
    readable, writable, exception = select.select(SOCKS,[],[],0)
    for s in readable:
      if s == server:
        sock, addr = server.accept()
        SOCKS.append(sock)
        print('{} connected to server'.format(addr))
        nicknames[sock] = addr
        broadcast(s,'{} connected to server'.format(addr))
      else:
        try:
          data = s.recv(4096)
        except ConnectionResetError:
          broadcast(s,'{} killed the connection'.format(nicknames[s]))
          print('{} killed the connection'.format(nicknames[s]))
          if s in SOCKS:
            SOCKS.remove(s)
          s.close()
          continue
        try:
          plaintext = enc.decrypt(data)
          assert plaintext
        except:
          continue
        if data:
          if plaintext.startswith('/help'):
            s.send(enc.encrypt('/nick <nickname> - change nickname'))
          elif plaintext.startswith('/nick '):
            broadcast(s,'{} changed their nickname to {}'.format(nicknames[s],plaintext[6:]))
            nicknames[s] = plaintext[6:].strip()
          else:
            broadcast(s,'{}: {}'.format(nicknames[s],plaintext))
        else:
          broadcast(s,'{} killed the connection'.format(nicknames[s]))
          print('{} killed the connection\n'.format(nicknames[s]))
          if s in SOCKS:
            SOCKS.remove(s)
          s.close()
    for s in exception:
      broadcast(s,'{} killed the connection'.format(nicknames[s]))
      print('{} killed the connection'.format(nicknames[s]))
      if s in SOCKS:
        SOCKS.remove(s)
      s.close()
def broadcast(sock,message):
  global server, SOCKS
  for s in SOCKS:
    if s != server:
      try:
        s.send(enc.encrypt(message))
      except:
        s.close()
        if s in SOCKS:
          SOCKS.remove(s)
chat_server()
client.py
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import ScreenManager
from kivy.properties import ObjectProperty
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.clock import Clock
import select
import socket
import sys
from encrypt import AESCipher
class Chat(Widget):
  tout = ObjectProperty(None)
  tin = ObjectProperty(None)
  send_btn = ObjectProperty(None)
  def __init__(self, *args, **kwargs):
    super(Chat, self).__init__(*args, **kwargs)
    self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.client.settimeout(2)
    self.enc = AESCipher('')
    self.connected = 0
    Clock.schedule_interval(self.chat_client, 0)
  def chat_client(self,e):
    self.tin.focus = True
    if self.connected:
      readable, writable, exception = select.select([self.client],[],[],0)
      if self.client in readable:
        data = self.client.recv(4096)
        if not data:
          self.tout.text = 'Server connection killed.'
        else:
          try:
            self.tout.text += '\n' + self.enc.decrypt(data)
          except:
            pass
  def send_msg(self):
    text = self.tin.text
    if text.startswith('#passwd '):
      self.enc = AESCipher(text[8:])
    elif text.startswith('#connect '):
      try:
        self.client.connect((text.split(' ')[1], int(text.split(' ')[2])))
        self.connected = 1
      except:
        self.tout.text += '\nConnection to {}:{} failed. If you\'ve already connected to a server, try restarting your client.'.format(text.split(' ')[1], text.split(' ')[2])
        self.connected = 0
    elif text == '#exit':
      sys.exit()
    elif self.connected:
      self.client.send(self.enc.encrypt(text))
    self.tin.text = ''
class Manager(ScreenManager):
  pass
class Main(App):
  def build(self):
    Builder.load_string('''
<Chat>:
  tout: tout
  tin: tin
  send_btn: send_btn
  TextInput:
    id: tout
    width: root.width
    height: root.height * 0.94
    y: root.height * 0.06
    text: "Use #connect <ip> <port> to connect to a server. Use the command `/help` to view a server's commands. Use #passwd <password> if the server you're connected to has encryption."
  TextInput:
    id: tin
    focus: True
    multiline: False
    width: root.width * 0.9
    height: root.height * 0.06
    on_text_validate: root.send_msg()
  Button:
    id: send_btn
    width: root.width * 0.1
    height: root.height * 0.06
    x: root.width * 0.9
    text: 'Send'
    on_press: root.send_msg()
<Manager>:
  Screen:
    name: 'chat'
    Chat:
      id: chat''')
    return Manager()
Main().run()
encrypt.py (the encryption snippet was taken from elsewhere - I wanted to focus on networking rather than learning how to use PyCrypto):
from hashlib import md5
from base64 import b64decode
from base64 import b64encode
from Crypto import Random
from Crypto.Cipher import AES
# Padding for the input string --not
# related to encryption itself.
BLOCK_SIZE = 16  # Bytes
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \
                chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
unpad = lambda s: s[:-ord(s[len(s) - 1:])]
class AESCipher:
    def __init__(self, key):
        self.key = md5(key.encode('utf8')).hexdigest()
    def encrypt(self, raw):
        raw = pad(raw)
        iv = Random.new().read(AES.block_size)
        cipher = AES.new(self.key.encode(), AES.MODE_CBC, iv)
        return b64encode(iv + cipher.encrypt(raw.encode()))
    def decrypt(self, enc):
        enc = b64decode(enc)
        iv = enc[:16]
        cipher = AES.new(self.key.encode(), AES.MODE_CBC, iv)
        return unpad(cipher.decrypt(enc[16:])).decode('utf8')
What I've aimed for is a secure chat server/client, where a number of people can connect. I'd like to focus on looking at:
How secure is this? Could it easily be wiretapped and am I making some stupid mistakes?
Is my code styled ok? Are my variable names properly representative of what they are etc.?
And most of all, is the server/client relationship fairly responsible and not ridiculous?