Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
KeyBlobHelpers.cs
Go to the documentation of this file.
2
3internal static class KeyBlobHelpers
4{
5 internal static byte[] ToUnsignedIntegerBytes(this ReadOnlyMemory<byte> memory, int length)
6 {
7 if (memory.Length == length)
8 {
9 return memory.ToArray();
10 }
11 ReadOnlySpan<byte> span = memory.Span;
12 if (memory.Length == length + 1 && span[0] == 0)
13 {
14 return span.Slice(1).ToArray();
15 }
16 if (span.Length > length)
17 {
19 }
20 byte[] array = new byte[length];
21 span.CopyTo(array.AsSpan(length - span.Length));
22 return array;
23 }
24
25 internal static byte[] ToUnsignedIntegerBytes(this ReadOnlyMemory<byte> memory)
26 {
27 ReadOnlySpan<byte> span = memory.Span;
28 if (span.Length > 1 && span[0] == 0)
29 {
30 return span.Slice(1).ToArray();
31 }
32 return span.ToArray();
33 }
34}
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static byte[] ToUnsignedIntegerBytes(this ReadOnlyMemory< byte > memory)
static byte[] ToUnsignedIntegerBytes(this ReadOnlyMemory< byte > memory, int length)
unsafe ReadOnlySpan< T > Span
void CopyTo(Span< T > destination)
ReadOnlySpan< T > Slice(int start)