code_junkie

Xor of string in ruby

Nov 12th, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.12 KB | None | 0 0
  1. lrc = 0
  2. input.each_byte do | c |
  3. lrc ^= c
  4. end
  5. hexVal = lrc.to_s(16)
  6.  
  7. input.bytes.inject { |a,b| a ^ b }.to_s(16)
Add Comment
Please, Sign In to add comment