Encoding/decoding using xor