class WebSocket::Driver::Draft76

def handshake_signature

def handshake_signature
  return nil unless @body.size >= BODY_SIZE
  head = @body[0...BODY_SIZE].pack('C*')
  head.force_encoding('ASCII-8BIT') if head.respond_to?(:force_encoding)
  env = @socket.env
  key1   = env['HTTP_SEC_WEBSOCKET_KEY1']
  value1 = number_from_key(key1) / spaces_in_key(key1)
  key2   = env['HTTP_SEC_WEBSOCKET_KEY2']
  value2 = number_from_key(key2) / spaces_in_key(key2)
  Digest::MD5.digest(big_endian(value1) +
                     big_endian(value2) +
                     head)
end