Method: Rex::Text.to_mixed_case_array

Defined in:
lib/rex/text/randomize.rb

.to_mixed_case_array(str) ⇒ Array<String>

Takes a string, and returns an array of all mixed case versions.

Examples:

>> Rex::Text.to_mixed_case_array "abc1"
=> ["abc1", "abC1", "aBc1", "aBC1", "Abc1", "AbC1", "ABc1", "ABC1"]

Parameters:

  • str (String)

    The string to randomize

Returns:

  • (Array<String>)

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/rex/text/randomize.rb', line 37

def self.to_mixed_case_array(str)
  letters = str.each_char.map { |l| [l.downcase, l.upcase] }
  (1 << str.size).times.map do |i| 
    this_str = ""
    ("%0#{str.size}b" % i).each_char.map(&:to_i).each_with_index do |d,i|
      this_str << letters[i][d]
    end
    this_str
  end.uniq
end