From: Brian Candler Date: 2009-01-13T18:20:48+09:00 Subject: Re: XOR two binary strings I'm not sure if "binary string" meant a string of the form "000101...", or if it meant two strings treated as arrays of bytes. If the latter, then irb(main):001:0> require 'enumerator' => true irb(main):002:0> s1 = "abc".to_enum(:each_byte) => # irb(main):003:0> s2 = "\x02\x04\x06".to_enum(:each_byte) => # irb(main):004:0> s1.zip(s2).map{ |x,y| (x^y).chr }.join => "cfe" ruby 1.9 lets you shorten this to irb(main):001:0> "abc".bytes.zip("\x02\x04\x06".bytes).map { |x,y| (x^y).chr }.join => "cfe" -- Posted via http://www.ruby-forum.com/.