code: def base64_encode_as_string(obj):  # noqa
      # type: (any) -> str
      
      if on_python2():
          return base64.b64encode(obj)
      else:
          return str(base64.b64encode(obj), 'ascii')
docs: Encode object to base64
      :param any obj: object to encode
      :rtype: str
      :return: base64 encoded string