I don’t know Ruby but I need to understand how the input value is manipulated in the lines below.
I think that the input is converted to the sum of the values of its characters but the second line is confusing; does it take the final value of the sum and perform the bitwise operations or per iteration? Could you provide a simple explanation of the steps followed?
Thank you in advance!
input.to_s.each_char.inject(0) do |sum, ch|
(sum << 8) ^ (ch.ord) ^ (sum >> 4)