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

◆ CircularCopyUtf16BE() [2/2]

static void System.Security.Cryptography.Pkcs.Pkcs12Kdf.CircularCopyUtf16BE ( ReadOnlySpan< char > password,
Span< byte > destination )
inlinestaticprivate

Definition at line 141 of file Pkcs12Kdf.cs.

142 {
143 int num = password.Length * 2;
144 Encoding bigEndianUnicode = Encoding.BigEndianUnicode;
145 while (destination.Length > 0)
146 {
147 if (destination.Length >= num)
148 {
149 int bytes = bigEndianUnicode.GetBytes(password, destination);
150 if (bytes != num)
151 {
152 throw new CryptographicException();
153 }
155 Span<byte> span = destination.Slice(0, Math.Min(2, destination.Length));
156 span.Clear();
157 destination = destination.Slice(span.Length);
158 continue;
159 }
160 ReadOnlySpan<char> chars = password.Slice(0, destination.Length / 2);
161 int bytes2 = bigEndianUnicode.GetBytes(chars, destination);
162 if (bytes2 != destination.Length)
163 {
164 throw new CryptographicException();
165 }
166 break;
167 }
168 }
static Encoding BigEndianUnicode
Definition Encoding.cs:521
virtual byte[] GetBytes(char[] chars)
Definition Encoding.cs:781
ReadOnlySpan< T > Slice(int start)

References System.Text.Encoding.BigEndianUnicode, System.bytes, System.chars, System.Span< T >.Clear(), System.destination, System.Text.Encoding.GetBytes(), System.Span< T >.Length, System.Math.Min(), System.ReadOnlySpan< T >.Slice(), and System.Span< T >.Slice().