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

◆ X500DistinguishedNameFormat()

unsafe string Internal.Cryptography.Pal.X509Pal.X500DistinguishedNameFormat ( byte[] encodedDistinguishedName,
bool multiLine )
inline

Implements Internal.Cryptography.Pal.IX509Pal.

Definition at line 506 of file X509Pal.cs.

507 {
508 if (encodedDistinguishedName == null || encodedDistinguishedName.Length == 0)
509 {
510 return string.Empty;
511 }
512 int dwFormatStrType = (multiLine ? 1 : 0);
513 int pcbFormat = 0;
514 if (!global::Interop.Crypt32.CryptFormatObject(1, 0, dwFormatStrType, IntPtr.Zero, (byte*)7, encodedDistinguishedName, encodedDistinguishedName.Length, null, ref pcbFormat))
515 {
516 return encodedDistinguishedName.ToHexStringUpper();
517 }
518 int num = (pcbFormat + 1) / 2;
519 Span<char> span = ((num > 256) ? ((Span<char>)new char[num]) : stackalloc char[num]);
520 Span<char> span2 = span;
521 fixed (char* pbFormat = span2)
522 {
523 if (!global::Interop.Crypt32.CryptFormatObject(1, 0, dwFormatStrType, IntPtr.Zero, (byte*)7, encodedDistinguishedName, encodedDistinguishedName.Length, pbFormat, ref pcbFormat))
524 {
525 return encodedDistinguishedName.ToHexStringUpper();
526 }
527 }
528 return new string(span2.Slice(0, pcbFormat / 2 - 1));
529 }
static readonly IntPtr Zero
Definition IntPtr.cs:18
Span< T > Slice(int start)
Definition Span.cs:271

References System.Span< T >.Slice(), and System.IntPtr.Zero.