# Sample raid5 syndrome def xor_byte(*bytes) bytes.inject(0) {|sum, arg| sum ^ arg[0] }.chr end def xor_block(*blocks) # Split blocks into arrays, zip them together, xor across them. blocks = blocks.map {|block| block.split(//) } blocks.shift.zip(*blocks).map {|bytes| xor_byte(*bytes) }.join end