Beispiel #1
0
 public static PemPart Create(PemPartTypes type, byte[] body)
 {
     return(new PemPart
     {
         Type = type,
         Body = body
     });
 }
Beispiel #2
0
 internal static PemPart Create(PemPartTypes type, params PemPart[] parts)
 {
     return(new PemPart
     {
         Type = type,
         Body = parts.Select(x => x.Serialize()).SelectMany(x => x).ToArray()
     });
 }
Beispiel #3
0
        public PemPart GetPartByType(PemPartTypes type)
        {
            int offset = 0;

            while (offset < Body.Length)
            {
                var currentType = Body[offset];
                if (currentType == (byte)type)
                {
                    return(Create(Body, offset));
                }
                offset += 2 + Body[offset + 1];
            }

            throw new KeyNotFoundException(nameof(type));
        }