title: How to implement Fernet encryption with AES 256
body: <p>I'm currently using <a href="https://cryptography.io/en/latest/fernet/" rel="nofollow noreferrer">Fernet</a> encryption which uses AES 128 keys. However my client requires using AES 256. I'm not very familiar with cryptography but here is what I understood so far.</p>
  
  <p>Fernet needs a 256 bits key that is splitted in half. First half is the signing key, second one is the encryption key. As they are 128 bits long it is AES 128.</p>
  
  <p>Would it be enough to double the input key and modify the implementation like below to get AES 256 ?</p>
  
  <pre><code>class Fernet(object):
      def __init__(self, key, backend=None):
          if backend is None:
              backend = default_backend()
  
          key = base64.urlsafe_b64decode(key) # Here 512 bits long instead of 256
  
          self._signing_key = key[:16] # double this
          self._encryption_key = key[16:] # double this
          self._backend = backend
  </code></pre>