code: def create_binary(self, key, value):
          
          data = None
          if key is not None and value is not None:
              try:
                  # py2
                  # convert to bytes as required for b64encode
                  # decode bytes for json serialization as required for json dumps
                  data = self.db.create(
                      key.strip(), json.dumps(base64.b64encode(bytes(value)).decode('utf-8'))
                  )
              except TypeError:
                  # py3
                  # set encoding on string and convert to bytes as required for b64encode
                  # decode bytes for json serialization as required for json dumps
                  data = self.db.create(
                      key.strip(), json.dumps(base64.b64encode(bytes(value, 'utf-8')).decode('utf-8'))
                  )
          else:
              self.tcex.log.warning(u'The key or value field was None.')
          return data
docs: Create method of CRUD operation for binary data.
  
          Args:
              key (string): The variable to write to the DB.
              value (any): The data to write to the DB.
  
          Returns:
              (string): Result of DB write.