signKey method

String signKey (
  1. String key

Signs a Sec-WebSocket-Key header sent by a WebSocket client as part of the initial handshake.

The return value should be sent back to the client in a Sec-WebSocket-Accept header.


static String signKey(String key) {
  // We use [codeUnits] here rather than UTF-8-decoding the string because
  // [key] is expected to be base64 encoded, and so will be pure ASCII.
  return convert.base64
      .encode(sha1.convert((key + webSocketGUID).codeUnits).bytes);