class String
Public Instance Methods
shellescape()
click to toggle source
File
shellwords.rb, line 72
# File lib/pedump/cli.rb, line 13 def shellescape # An empty argument will be skipped, so return empty quotes. return "''" if self.empty? str = self.dup # Process as a single byte sequence because not all shell # implementations are multibyte aware. str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1") # A LF cannot be escaped with a backslash because a backslash + LF # combo is regarded as line continuation and simply ignored. str.gsub!(/\n/, "'\n'") str end
xor(x)
click to toggle source
# File lib/pedump/core.rb, line 6 def xor x if x.is_a?(String) r = '' j = 0 0.upto(self.size-1) do |i| r << (self[i].ord^x[j].ord).chr j+=1 j=0 if j>= x.size end r else r = '' 0.upto(self.size-1) do |i| r << (self[i].ord^x).chr end r end end