The functions included are for generating the base64-encode of a sha1 hash of the input string sent in as an argument.
This is the mechanism for processing something to be used as the header for either the Sec-WebSocket-Key
request header or Sec-WebSocket-Accept
response header in the websocket opening handshake.
To generate the Sec-WebSocket-Key
, you would use generateRandomBase64String
; for the matching Sec-WebSocket-Accept
header value, you would use base64EncodeOfSha1Hash(keyConcatenatedWithMagicString)
.