Sha256: edd11c1ab31ad6efaa528664f63f75580a60dd4b21949020dfb2640552a3f142

Contents?: true

Size: 1.12 KB

Versions: 42

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby

module Rex
module Encoder

###
#
# This class performs basic XOR encoding.
#
###
class Xor

	attr_accessor :raw, :encoded, :badchars, :opts, :key, :fkey # :nodoc:

	#
	# wrap that in a wanna be static class
	#
	def self.encode(*args)
		self.new.encode(*args)
	end

	#
	# Return the class associated with this encoder.
	#
	def encoder()
		self.class::EncoderKlass
	end

	#
	# This method encodes the supplied data, taking into account the badchar
	# list, and returns the encoded buffer.
	#
	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

	protected
	def _unencoded_transform(data) # :nodoc:
		data
	end

	def _encoded_transform(data) # :nodoc:
		data
	end

	def _prepend() # :nodoc:
		""
	end

	def _append() # :nodoc:
		""
	end

end

end end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
librex-0.0.35 lib/rex/encoder/xor.rb
librex-0.0.34 lib/rex/encoder/xor.rb
librex-0.0.33 lib/rex/encoder/xor.rb
librex-0.0.32 lib/rex/encoder/xor.rb
librex-0.0.30 lib/rex/encoder/xor.rb
librex-0.0.29 lib/rex/encoder/xor.rb
librex-0.0.28 lib/rex/encoder/xor.rb
librex-0.0.27 lib/rex/encoder/xor.rb
librex-0.0.26 lib/rex/encoder/xor.rb
librex-0.0.25 lib/rex/encoder/xor.rb
librex-0.0.23 lib/rex/encoder/xor.rb
librex-0.0.21 lib/rex/encoder/xor.rb
librex-0.0.19 lib/rex/encoder/xor.rb
librex-0.0.17 lib/rex/encoder/xor.rb
librex-0.0.13 lib/rex/encoder/xor.rb
librex-0.0.12 lib/rex/encoder/xor.rb
librex-0.0.7 lib/rex/encoder/xor.rb
librex-0.0.6 lib/rex/encoder/xor.rb
librex-0.0.5 lib/rex/encoder/xor.rb
librex-0.0.4 lib/rex/encoder/xor.rb