code: def encrypt(self, plaintext):
          
  
          # String to bytes.
          plainbytes = plaintext.encode('utf8')
  
          # Compress plaintext bytes.
          compressed = zlib.compress(plainbytes)
  
          # Construct AES-GCM cipher, with 96-bit nonce.
          cipher = AES.new(self.cipher_key, AES.MODE_GCM, nonce=random_bytes(12))
  
          # Encrypt and digest.
          encrypted, tag = cipher.encrypt_and_digest(compressed)
  
          # Combine with nonce.
          combined = cipher.nonce + tag + encrypted
  
          # Encode as Base64.
          cipherbytes = base64.b64encode(combined)
  
          # Bytes to string.
          ciphertext = cipherbytes.decode('utf8')
  
          # Return ciphertext.
          return ciphertext
docs: Return ciphertext for given plaintext.