import zlib
import base64
import six


def compressText(data):
  """
  returns compressed data in base64 format

  :param data: Data to be compressed

  """
  compressor = zlib.compressobj(9, zlib.DEFLATED, zlib.MAX_WBITS | 16)
  zContent = compressor.compress(six.ensure_binary(data)) + compressor.flush()
  return base64.b64encode(zContent)