Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateSecKeyAndSecWebSocketAccept()

static KeyValuePair< string, string > System.Net.WebSockets.WebSocketHandle.CreateSecKeyAndSecWebSocketAccept ( )
inlinestaticprivate

Definition at line 374 of file WebSocketHandle.cs.

375 {
376 ReadOnlySpan<byte> readOnlySpan = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"u8;
377 Span<byte> span = stackalloc byte[24 + readOnlySpan.Length];
378 bool flag = Guid.NewGuid().TryWriteBytes(span);
379 string text = Convert.ToBase64String(span.Slice(0, 16));
380 for (int i = 0; i < text.Length; i++)
381 {
382 span[i] = (byte)text[i];
383 }
384 readOnlySpan.CopyTo(span.Slice(text.Length));
386 return new KeyValuePair<string, string>(text, Convert.ToBase64String(span.Slice(0, bytesWritten)));
387 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
Definition SHA1.cs:91

References System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.Guid.NewGuid(), System.text, System.Convert.ToBase64String(), and System.Security.Cryptography.SHA1.TryHashData().

Referenced by System.Net.WebSockets.WebSocketHandle.ConnectAsync().