module Rubymisc::String

Public Instance Methods

^(key) click to toggle source
# File lib/rubymisc/ext/string.rb, line 5
def ^(key)
  key_bytes = key.bytes.cycle
  xor_proc = ->(byte) { byte ^ key_bytes.next }
  bytes.map(&xor_proc).pack('C*').force_encoding(self.encoding)
end
Also aliased as: xor
xor(key)
Alias for: ^