Skip to content
instance method

IO::Buffer#xor!

source.xor!(mask) → io_buffer

Modify the source buffer in place by applying the binary XOR operation to the source, using the mask, repeating as necessary.

Example
source = IO::Buffer.for("1234567890").dup # Make a read/write copy.
# =>
# #<IO::Buffer 0x000056307a25b3e0+10 INTERNAL>
# 0x00000000  31 32 33 34 35 36 37 38 39 30                   1234567890

source.xor!(IO::Buffer.for("\xFF\x00\x00\xFF"))
# =>
# #<IO::Buffer 0x000056307a25b3e0+10 INTERNAL>
# 0x00000000  ce 32 33 cb ca 36 37 c7 c6 30                   .23..67..0
See also #write #values also in 4.1 · 3.4 · 3.3 · 3.2