title: python decode fernet key
body: <p>I have generated few fernet keys and stored in str format for reference.
  Now, I need to encode these fernet keys in str format to 32 url-safe base64-encoded bytes to decrypt my data.</p>
  
  <pre><code>from cryptography.fernet import Fernet as frt
  keys=set()
  keybin='keys'
  keybin=open(keybin,'w')
  
  for i in range(r.randint(5,14)):
   key=frt.generate_key()
   keys.add(key.decode())
  
  for k in keys:
   keybin.write(str(k))
   keybin.write('\n')
  </code></pre>
  
  <p>I'm using below code to access the file and decrypt <code>s</code></p>
  
  <pre><code> key=linecache.getline(cfile,x).encode()
   key=base64.b64encode(key)
   print(key)
   f=frt(key)
   token =f.decrypt(s.encode())
  </code></pre>
  
  <p>But is giving me the below error:</p>
  
  <pre><code>    "Fernet key must be 32 url-safe base64-encoded bytes."
  ValueError: Fernet key must be 32 url-safe base64-encoded bytes.
  </code></pre>