def bytearray_to_long(byte_array):
    """
  Converts a byte array to long.

  :param byte_array:
      The byte array.
  :returns:
      Long.
  """
    total = 0
    multiplier = 1
    for count in range(len(byte_array) - 1, -1, -1):
        byte_val = byte_array[count]
        total += multiplier * byte_val
        multiplier *= 256
    return total
