Method: Rex::Text.to_rand_case

Defined in:
lib/rex/text.rb

.to_rand_case(str) ⇒ String

Converts a string to random case

Examples:

Rex::Text.to_rand_case("asdf") # => "asDf"

Parameters:

  • str (String)

    The string to randomize

Returns:

  • (String)

See Also:



875
876
877
878
879
880
881
# File 'lib/rex/text.rb', line 875

def self.to_rand_case(str)
  buf = str.dup
  0.upto(str.length) do |i|
    buf[i,1] = rand(2) == 0 ? str[i,1].upcase : str[i,1].downcase
  end
  return buf
end