Stdlibnet::ws
handshake
import std::net::ws::handshake; · source
The opening handshake
function generate_key() -> String;
function compute_accept(client_key: Str) -> String;
The two computations RFC 6455 section 4 asks for. generate_key is the client's Sec-WebSocket-Key: 16 random bytes from the OS entropy source, base64-encoded. compute_accept is the server's Sec-WebSocket-Accept for a given client key — base64(sha1(key + GUID)) with the fixed RFC GUID — which the client checks against what it sent.
The HTTP/1.1 Upgrade exchange around them lives in WebSocket::client_handshake and server_handshake. Both digests come from encoding, pure Cryo, so the handshake needs no OpenSSL.