def decrypt(encrypted_message, key): key = base64.urlsafe_b64encode(codecs.decode(key, 'hex')) f = Fernet(key) return f.decrypt(encrypted_message.encode('utf-8')).decode('utf-8')