    def _encrypt(self, data):
        """Actually do the encryption. Runs in a background thread.

        data is serialized to bytes with pickle.
        bytes are returned.
        """
        return self.fernet.encrypt(json.dumps(data).encode('utf8'))
Actually do the encryption. Runs in a background thread.

data is serialized to bytes with pickle.
bytes are returned.
jupyterhub/crypto.py