MCPcopy Index your code
hub / github.com/python-websockets/websockets / generate_key

Function generate_key

src/websockets/utils.py:17–23  ·  view source on GitHub ↗

Generate a random key for the Sec-WebSocket-Key header.

()

Source from the content-addressed store, hash-verified

15
16
17def generate_key() -> str:
18 """
19 Generate a random key for the Sec-WebSocket-Key header.
20
21 """
22 key = secrets.token_bytes(16)
23 return base64.b64encode(key).decode()
24
25
26def accept_key(key: str) -> str:

Callers 3

test_generate_keyMethod · 0.90
__init__Method · 0.85
build_requestFunction · 0.85

Calls 1

decodeMethod · 0.45

Tested by 1

test_generate_keyMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…