Method: WebSocket::Frame::Data#mask

Defined in:
lib/websocket/frame/data.rb

#mask(payload, mask) ⇒ Object

Mask whole payload using mask key



39
40
41
42
43
44
45
46
# File 'lib/websocket/frame/data.rb', line 39

def mask(payload, mask)
  return mask_native(payload, mask) if respond_to?(:mask_native)
  result = []
  payload.each_with_index do |byte, i|
    result[i] = byte ^ mask[i % 4]
  end
  result
end