예제 #1
0
        public static bool TryReadFrom(Stream inputStream, out OpenPgpPacketHeader readPacketHeader)
        {
            int firstByteRaw = inputStream.ReadByte();

            if (firstByteRaw < 0)
            {
                readPacketHeader = null;
                return(false);
            }

            var firstByte = (byte)firstByteRaw;

            if ((firstByte & NewHeaderHighBits) == NewHeaderHighBits)
            {
                readPacketHeader = new OpenPgpPacketHeader(firstByte, inputStream);
                return(true);
            }
            if ((firstByte & OpenPgpOldFormatPacketHeader.OldHeaderHighBits) == OpenPgpOldFormatPacketHeader.OldHeaderHighBits)
            {
                readPacketHeader = new OpenPgpOldFormatPacketHeader(firstByte, inputStream);
                return(true);
            }
            readPacketHeader = null;
            return(false);
        }
예제 #2
0
        public static bool TryReadFrom(Stream inputStream, out OpenPgpPacketHeader readPacketHeader)
        {
            int firstByteRaw = inputStream.ReadByte();
            if(firstByteRaw < 0) {
                readPacketHeader = null;
                return false;
            }

            var firstByte = (byte) firstByteRaw;

            if((firstByte & NewHeaderHighBits) == NewHeaderHighBits) {
                readPacketHeader = new OpenPgpPacketHeader(firstByte, inputStream);
                return true;
            }
            if((firstByte & OpenPgpOldFormatPacketHeader.OldHeaderHighBits) == OpenPgpOldFormatPacketHeader.OldHeaderHighBits) {
                readPacketHeader = new OpenPgpOldFormatPacketHeader(firstByte, inputStream);
                return true;
            }
            readPacketHeader = null;
            return false;
        }