indexing description: "[ Generate a checksum over a string. Current implementation only uses some bit shifting and some bitwise xor. ]" date: "$Date$" revision: "$Revision$" class EM_CHECKSUM_GENERATOR feature -- Reset reset is -- reset the checksum do create string.make_empty checksum := 0 end feature -- Generate Checksum append_string (a_string: STRING) is -- append `a_string' to string require string_created: string /= void do string.append_string(a_string) end generate_checksum is -- generate checksum for `string' local i, j: INTEGER a_char: CHARACTER do from i := 1 j := 0 until i > string.count loop a_char := string.item (i) if a_char.is_alpha or else a_char.is_digit then checksum := checksum.bit_xor (a_char.code.bit_shift_left ((j \\ 4) * 8)) j := j + 1 end i := i + 1 end end feature -- Attributes string: STRING -- String for which the checksum will be generated checksum: INTEGER -- Calculated checksum end