code: def _base64_encode(self, string_to_encode):
          
          try:
              # python 2
              return base64.b64encode(string_to_encode)
          except TypeError:
              # python 3
              encoding = sys.getdefaultencoding()
              base64_bytes = base64.b64encode(bytes(string_to_encode, encoding))
              return base64_bytes.decode(encoding)
docs: Base64 encodes a string, with either Python 2 or 3.
  
          :param string_to_encode: the string to encode