Skip to content

Instantly share code, notes, and snippets.

@dojekon
Last active March 31, 2020 17:22
Show Gist options
  • Save dojekon/9659cc7c94c3a27e890da492b5ca75c1 to your computer and use it in GitHub Desktop.
Save dojekon/9659cc7c94c3a27e890da492b5ca75c1 to your computer and use it in GitHub Desktop.
C#: Generate "Sec-WebSocket-Key"
static string GenerateWebSocketKey() {
byte[] code = new Byte[16];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(code);
return Convert.ToBase64String(code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment