# File lib/origami/obfuscation.rb, line 40 def self.junk_array(max_size = 5) length = rand(max_size) + 1 ::Array.new(length) { obj = Obfuscator.junk_object until (not obj.nil? and not obj.is_a?(Stream)) ; obj }.to_o end
# File lib/origami/obfuscation.rb, line 48 def self.junk_boolean Boolean.new(rand(2).zero?) end
# File lib/origami/obfuscation.rb, line 17 def self.junk_comment(max_size = 15) length = rand(max_size) + 1 junk_comment = ::Array.new(length) { byte = rand(256).chr until (not byte.nil? and byte != "\n" and byte != "\r"); byte }.join "%#{junk_comment}#{EOL}" end
# File lib/origami/obfuscation.rb, line 52 def self.junk_dictionary(max_size = 5) length = rand(max_size) + 1 hash = Hash.new length.times do obj = Obfuscator.junk_object hash[Obfuscator.junk_name] = obj unless obj.is_a?(Stream) end hash.to_o end
# File lib/origami/obfuscation.rb, line 64 def self.junk_integer(max = MAX_INT) Integer.new(rand(max + 1)) end
# File lib/origami/obfuscation.rb, line 68 def self.junk_name(max_size = 8) length = rand(max_size) + 1 Name.new(::Array.new(length) { PRINTABLE[rand(PRINTABLE.size)] }.join) end
# File lib/origami/obfuscation.rb, line 74 def self.junk_null Null.new end
# File lib/origami/obfuscation.rb, line 27 def self.junk_object(type = nil) if type.nil? type = OBJECTS[rand(OBJECTS.size)] end unless type.include?(Origami::Object) raise TypeError, "Not a valid object type" end Obfuscator.send("junk_#{type.to_s.split('::').last.downcase}") end
# File lib/origami/obfuscation.rb, line 102 def self.junk_real Real.new(rand * rand(MAX_INT + 1)) end
# File lib/origami/obfuscation.rb, line 106 def self.junk_reference(max_no = 300, max_gen = 1) no = rand(max_no) + 1 gen = rand(max_gen) Reference.new(no, gen) end
# File lib/origami/obfuscation.rb, line 11 def self.junk_spaces(max_size = 3) length = rand(max_size) + 1 ::Array.new(length) { WHITECHARS[rand(WHITECHARS.size)] }.join end
# File lib/origami/obfuscation.rb, line 78 def self.junk_stream(max_data_size = 200) chainlen = rand(2) + 1 chain = ::Array.new(chainlen) { FILTERS[rand(FILTERS.size)] } length = rand(max_data_size) + 1 junk_data = ::Array.new(length) { rand(256).chr }.join stm = Stream.new stm.dictionary = Obfuscator.junk_dictionary(5) stm.setFilter(chain) stm.data = junk_data stm end
Generated with the Darkfish Rdoc Generator 2.