Method: Rex::Text.to_csharp

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

.to_csharp(str, wrap = DefaultWrap, name = "buf") ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/text/lang.rb', line 30

def self.to_csharp(str, wrap = DefaultWrap, name = "buf")
  ret = "byte[] #{name} = new byte[#{str.length}] {"
  i = -1;
  while (i += 1) < str.length
    ret << "\n" if i%(wrap/4) == 0
    ret << "0x" << str[i].unpack("H*")[0] << ","
  end
  ret = ret[0..ret.length-2] #cut off last comma
  ret << " };\n"
end