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

◆ ReadCryptoBinary()

static byte[] System.Security.Cryptography.XmlKeyHelper.ReadCryptoBinary ( ref ParseState state,
string name,
int sizeHint = -1 )
inlinestaticpackage

Definition at line 158 of file XmlKeyHelper.cs.

159 {
160 string value = state.GetValue(name);
161 if (value == null)
162 {
163 return null;
164 }
165 if (value.Length == 0)
166 {
167 return Array.Empty<byte>();
168 }
169 if (sizeHint < 0)
170 {
171 return Convert.FromBase64String(value);
172 }
173 byte[] array = new byte[sizeHint];
174 if (Convert.TryFromBase64Chars(value.AsSpan(), array, out var bytesWritten))
175 {
176 if (bytesWritten == sizeHint)
177 {
178 return array;
179 }
180 int num = sizeHint - bytesWritten;
181 Buffer.BlockCopy(array, 0, array, num, bytesWritten);
182 array.AsSpan(0, num).Clear();
183 return array;
184 }
185 return Convert.FromBase64String(value);
186 }

References System.array, System.Buffer.BlockCopy(), System.Convert.FromBase64String(), System.state, System.Convert.TryFromBase64Chars(), and System.value.

Referenced by System.Security.Cryptography.DSA.FromXmlString(), System.Security.Cryptography.RSA.FromXmlString(), System.Security.Cryptography.DSA.ReadRequiredElement(), and System.Security.Cryptography.RSA.ReadRequiredElement().