title: Fernet error: token must be bytes, When decrypting content received through socket connection
body: <p>I'm trying to make a simple file transfer system through socket, by encrypting file bytes and sending them to an ip address on my LAN, then, receiving them on the other machine, decrytpint the content and saving it toa file (So basically i'm copying the file content and sending it to an other machine) and here somes the problem... When i try to decrypt the content with the kay it outputs the following error:</p>
  <p><em>Exception has occurred: TypeError
  token must be bytes
  File &quot;C:\Users\windows 10 pro\Desktop\FileTransfer\receiver.py&quot;, line 57, in get
  decrypteddata = fern.decrypt(encrypted_bytes1, ttl=None)</em></p>
  <p>Has anyone had this issue before ? can you help ? Thanks.
  here are the <em>sender</em> and <em>receiver</em> files:</p>
  <p><strong>Receiver.py</strong></p>
  <pre><code>from logging import exception
  from cryptography.fernet import Fernet
  from socket import *
  import winsound
  
  fern = Fernet(bytes('b8wa6JrivmDLFGURRUUpw6rVkiE5W9BL4GWLYFZdoFk=', 'utf-8'))
  
  port = 42069
  s = socket(AF_INET, SOCK_STREAM)
  s.bind(('0.0.0.0', port))
  s.listen(1)
  
  try:
      c, addr = s.accept()
      print(&quot;Connection successfull.\n&quot;)
  except:
      print('Connection error.\n')
  
  def get():
      val = 0
      while True:
          data = c.recv(1024)
          if not data:
              pass
          else:
              val += 1
              if val == 1:    
                  try:
                      global f
                      data1 = str(data.decode())
                      data2 = data1.split('/')[-1]
                      f = open(str(data2), 'wb')
                      print('Created file: ', data2)
                  except:
                      print('3RR0R1\n')
              else:
  
                  data1 = data.decode()
  
                  print(data1)
                  encrypted_bytes = str(data).encode()
  
                  print(encrypted_bytes1)
  
                  decrypteddata = fern.decrypt(encrypted_bytes1, ttl=None)
  
                  print('typing')
                  f.write(decrypteddata)
                  f.close()
                  print(&quot;Received file Soccessfully\n&quot;)
                  winsound.Beep(600, 200)
                  print(exception)
                  break
  
  get()
  </code></pre>
  <p><strong>Sender.py</strong></p>
  <pre><code>from socket import *
  import tkinter as tk
  from tkinter import filedialog as fd
  
  from cryptography.fernet import Fernet
  
  fern = Fernet(b'b8wa6JrivmDLFGURRUUpw6rVkiE5W9BL4GWLYFZdoFk=')
  
  port = 42069
  s = socket(AF_INET, SOCK_STREAM)
  s.connect(('192.168.0.171', port))
  
  m = tk.Tk()
  m.title('File Trans')
  m.geometry(&quot;800x800&quot;)
  
  def send(filename):
      f = open(filename, 'rb')
      message = f.read()
      s.send('file.txt'.encode())
      encrypteddata = fern.encrypt(message)
      s.send(encrypteddata)
  
  
  filename = fd.askopenfilename()
  send(filename)
  </code></pre>