search for: clear_char

Displaying 1 result from an estimated 1 matches for "clear_char".

Did you mean: clear_chan
2012 Feb 04
3
the ^ and % operators in context
The % is modulus (remainder) operator and ^ is bitwise. In this context, we take a file, and go through each character and encrypt it. But why are the ^ and % operators used here: def encrypt(reader, writer) key_index = 0 while not reader.eof? clear_char = reader.getc encrypted_char = clear_char ^ @key[key_index] writer.putc(encrypted_char) key_index = (key_index + 1) % @key.size end end thanks for response -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group....