Method: Kaitai::Struct::Stream.process_xor_one
- Defined in:
- lib/kaitai/struct/struct.rb
.process_xor_one(data, key) ⇒ String
Performs a XOR processing with given data, XORing every byte of input with a single given value. Uses pure Ruby implementation suggested by [Thomas Leitner](github.com/gettalong), borrowed from github.com/fny/xorcist/blob/master/bin/benchmark
502 503 504 505 506 507 508 509 510 511 |
# File 'lib/kaitai/struct/struct.rb', line 502 def self.process_xor_one(data, key) out = data.dup i = 0 max = data.length while i < max out.setbyte(i, data.getbyte(i) ^ key) i += 1 end out end |