Method: Rex::Text.to_num

Defined in:
lib/rex/text.rb

.to_num(str, wrap = DefaultWrap) ⇒ Object

Creates a comma separated list of numbers



179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rex/text.rb', line 179

def self.to_num(str, wrap = DefaultWrap)
  code = str.unpack('C*')
  buff = ""
  0.upto(code.length-1) do |byte|
    if(byte % 15 == 0) and (buff.length > 0)
      buff << "\r\n"
    end
    buff << sprintf('0x%.2x, ', code[byte])
  end
  # strip , at the end
  buff = buff.chomp(', ')
  buff << "\r\n"
  return buff
end