A file is divided into plural segments, and for each of at least some of the plural segments, plural windows covering different portions of the corresponding segment are defined. According to a predefined criterion, one of the windows associated with the corresponding segment is selected. A representative hash based on the portion in the selected window is calculated for representing the corresponding segment.