Method: Rex::Encoder::Xor#encode

Defined in:
lib/rex/encoder/xor.rb

#encode(data, badchars = '', opts = { }) ⇒ Object

This method encodes the supplied data, taking into account the badchar list, and returns the encoded buffer.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rex/encoder/xor.rb', line 33

def encode(data, badchars = '', opts = { })
  self.raw      = data
  self.badchars = badchars
  self.opts     = opts

  # apply any transforms to the plaintext data
  data = _unencoded_transform(data)

  self.encoded, self.key, self.fkey = encoder().find_key_and_encode(data, badchars)

  # apply any transforms to the encoded data
  self.encoded = _encoded_transform(encoded)

  return _prepend() + encoded + _append()
end