Home Contents | # websocket.acceptKey | Websocket | Core4 Lua Event System

## SYNOPSIS

accept = websocket.acceptKey(key)

## DESCRIPTION

This helper function calculates the value for the header Sec-WebSocket-Accept from the value of the header Sec-WebSocket-Key.

The client sends a Sec-WebSocket-Key which is a random value that has been base64 encoded. To form a response, the GUID 258EAFA5-E914-47DA-95CA-C5AB0DC85B11 is appended to this base64 encoded key. The base64 encoded key will not be decoded first. The resulting string is then hashed with SHA-1, then base64 encoded. Finally, the resulting reply occurs in the header Sec-WebSocket-Accept. From Wikipedia.

## RETURN VALUE

Base64 encoded string.