def Checksum(payload, payload_size):
  """Calculates the checksum of the payload.

  Args:
    payload: (string)
      The payload string for which checksum needs to be calculated.
    payload_size: (int)
      The number of bytes in the payload.

  Returns:
    The checksum of the payload.
  """
  checksum = 0
  length = min(payload_size, len(payload))
  for i in range (0, length):
    checksum += ord(payload[i])
  return checksum