WriteInt() приватный Метод

private WriteInt ( int n ) : void
n int
Результат void
Пример #1
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);

            if (version == 3 || version == 2)
            {
                pOut.Write(
                    5,                     // the length of the next block
                    (byte)signatureType);

                pOut.WriteInt((int)(creationTime / 1000L));

                pOut.WriteLong(keyId);

                pOut.Write(
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);
            }
            else if (version == 4)
            {
                pOut.Write(
                    (byte)signatureType,
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);

                EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));

                EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
            }
            else
            {
                throw new IOException("unknown version: " + version);
            }

            pOut.Write(fingerprint);

            if (signature != null)
            {
                pOut.WriteObjects(signature);
            }
            else
            {
                pOut.Write(signatureEncoding);
            }

            bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
        }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.WriteByte((byte)_version);

                    switch (_version)
                    {
                    case 2:
                    case 3:
                        pOut.Write(
                            5,     // the length of the next block
                            (byte)_signatureType);
                        pOut.WriteInt((int)(CreationTime / 1000L));
                        pOut.WriteLong(_keyId);
                        pOut.Write(
                            (byte)_keyAlgorithm,
                            (byte)_hashAlgorithm);
                        break;

                    case 4:
                        pOut.Write(
                            (byte)_signatureType,
                            (byte)_keyAlgorithm,
                            (byte)_hashAlgorithm);
                        EncodeLengthAndData(pOut, GetEncodedSubpackets(_hashedData));
                        EncodeLengthAndData(pOut, GetEncodedSubpackets(_unhashedData));
                        break;

                    default:
                        throw new IOException("unknown version: " + _version);
                    }

                    pOut.Write(_fingerprint);

                    if (_signature != null)
                    {
                        pOut.WriteObjects(_signature);
                    }
                    else
                    {
                        pOut.Write(_signatureEncoding);
                    }

                    bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
                }
            }
        }
Пример #3
0
        public virtual byte[] GetEncodedContents()
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.WriteByte((byte)this.version);
            bcpgOutputStream.WriteInt((int)this.time);
            if (this.version <= 3)
            {
                bcpgOutputStream.WriteShort((short)this.validDays);
            }
            bcpgOutputStream.WriteByte((byte)this.algorithm);
            bcpgOutputStream.WriteObject((BcpgObject)this.key);
            return(memoryStream.ToArray());
        }
Пример #4
0
        public override void Encode(BcpgOutputStream bcpgOut)
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.WriteByte((byte)this.version);
            if (this.version == 3 || this.version == 2)
            {
                bcpgOutputStream.Write(new byte[]
                {
                    5,
                    (byte)this.signatureType
                });
                bcpgOutputStream.WriteInt((int)(this.creationTime / 1000L));
                bcpgOutputStream.WriteLong(this.keyId);
                bcpgOutputStream.Write(new byte[]
                {
                    (byte)this.keyAlgorithm,
                    (byte)this.hashAlgorithm
                });
            }
            else
            {
                if (this.version != 4)
                {
                    throw new IOException("unknown version: " + this.version);
                }
                bcpgOutputStream.Write(new byte[]
                {
                    (byte)this.signatureType,
                    (byte)this.keyAlgorithm,
                    (byte)this.hashAlgorithm
                });
                SignaturePacket.EncodeLengthAndData(bcpgOutputStream, SignaturePacket.GetEncodedSubpackets(this.hashedData));
                SignaturePacket.EncodeLengthAndData(bcpgOutputStream, SignaturePacket.GetEncodedSubpackets(this.unhashedData));
            }
            bcpgOutputStream.Write(this.fingerprint);
            if (this.signature != null)
            {
                bcpgOutputStream.WriteObjects(this.signature);
            }
            else
            {
                bcpgOutputStream.Write(this.signatureEncoding);
            }
            bcpgOut.WritePacket(PacketTag.Signature, memoryStream.ToArray(), true);
        }
Пример #5
0
        public virtual byte[] GetEncodedContents()
        {
            //IL_0000: Unknown result type (might be due to invalid IL or missing references)
            //IL_0006: Expected O, but got Unknown
            MemoryStream     val = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream((Stream)(object)val);

            ((Stream)bcpgOutputStream).WriteByte((byte)version);
            bcpgOutputStream.WriteInt((int)time);
            if (version <= 3)
            {
                bcpgOutputStream.WriteShort((short)validDays);
            }
            ((Stream)bcpgOutputStream).WriteByte((byte)algorithm);
            bcpgOutputStream.WriteObject((BcpgObject)key);
            return(val.ToArray());
        }
Пример #6
0
        public byte[] GetEncodedContents()
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);
            pOut.WriteInt((int)time);

            if (version <= 3)
            {
                pOut.WriteShort((short)validDays);
            }

            pOut.WriteByte((byte)algorithm);

            pOut.WriteObject((BcpgObject)key);

            return(bOut.ToArray());
        }
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.WriteByte((byte)_version);
                    pOut.WriteInt((int)_time);

                    if (_version <= 3)
                    {
                        pOut.WriteShort((short)_validDays);
                    }

                    pOut.WriteByte((byte)_algorithm);

                    pOut.WriteObject((BcpgObject)_key);

                    return(bOut.ToArray());
                }
            }
        }
Пример #8
0
        public override void Encode(BcpgOutputStream bcpgOut)
        {
            //IL_0000: Unknown result type (might be due to invalid IL or missing references)
            //IL_0006: Expected O, but got Unknown
            //IL_00fa: Unknown result type (might be due to invalid IL or missing references)
            MemoryStream     val = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream((Stream)(object)val);

            ((Stream)bcpgOutputStream).WriteByte((byte)version);
            if (version == 3 || version == 2)
            {
                bcpgOutputStream.Write(5, (byte)signatureType);
                bcpgOutputStream.WriteInt((int)(creationTime / 1000));
                bcpgOutputStream.WriteLong(keyId);
                bcpgOutputStream.Write((byte)keyAlgorithm, (byte)hashAlgorithm);
            }
            else
            {
                if (version != 4)
                {
                    throw new IOException(string.Concat((object)"unknown version: ", (object)version));
                }
                bcpgOutputStream.Write((byte)signatureType, (byte)keyAlgorithm, (byte)hashAlgorithm);
                EncodeLengthAndData(bcpgOutputStream, GetEncodedSubpackets(hashedData));
                EncodeLengthAndData(bcpgOutputStream, GetEncodedSubpackets(unhashedData));
            }
            bcpgOutputStream.Write(fingerprint);
            if (signature != null)
            {
                bcpgOutputStream.WriteObjects(signature);
            }
            else
            {
                bcpgOutputStream.Write(signatureEncoding);
            }
            bcpgOut.WritePacket(PacketTag.Signature, val.ToArray(), oldFormat: true);
        }
Пример #9
0
		public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

			pOut.WriteByte((byte) version);

			if (version == 3 || version == 2)
            {
				pOut.Write(
					5, // the length of the next block
					(byte) signatureType);

				pOut.WriteInt((int)(creationTime / 1000L));

				pOut.WriteLong(keyId);

				pOut.Write(
					(byte) keyAlgorithm,
					(byte) hashAlgorithm);
            }
            else if (version == 4)
            {
                pOut.Write(
					(byte) signatureType,
					(byte) keyAlgorithm,
					(byte) hashAlgorithm);

				EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));

				EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
            }
            else
            {
                throw new IOException("unknown version: " + version);
            }

			pOut.Write(fingerprint);

			if (signature != null)
			{
				pOut.WriteObjects(signature);
			}
			else
			{
				pOut.Write(signatureEncoding);
			}

			bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
        }
Пример #10
0
        public byte[] GetEncodedContents()
        {
            MemoryStream bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte) version);
            pOut.WriteInt((int) time);

			if (version <= 3)
            {
                pOut.WriteShort((short) validDays);
            }

			pOut.WriteByte((byte) algorithm);

			pOut.WriteObject((BcpgObject)key);

			return bOut.ToArray();
        }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {

                    pOut.WriteByte((byte)_version);

                    switch (_version)
                    {
                        case 2:
                        case 3:
                            pOut.Write(
                                5, // the length of the next block
                                (byte)_signatureType);
                            pOut.WriteInt((int)(CreationTime / 1000L));
                            pOut.WriteLong(_keyId);
                            pOut.Write(
                                (byte)_keyAlgorithm,
                                (byte)_hashAlgorithm);
                            break;
                        case 4:
                            pOut.Write(
                                (byte)_signatureType,
                                (byte)_keyAlgorithm,
                                (byte)_hashAlgorithm);
                            EncodeLengthAndData(pOut, GetEncodedSubpackets(_hashedData));
                            EncodeLengthAndData(pOut, GetEncodedSubpackets(_unhashedData));
                            break;
                        default:
                            throw new IOException("unknown version: " + _version);
                    }

                    pOut.Write(_fingerprint);

                    if (_signature != null)
                    {
                        pOut.WriteObjects(_signature);
                    }
                    else
                    {
                        pOut.Write(_signatureEncoding);
                    }

                    bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
                }
            }
        }
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {

                    pOut.WriteByte((byte)_version);
                    pOut.WriteInt((int)_time);

                    if (_version <= 3)
                    {
                        pOut.WriteShort((short)_validDays);
                    }

                    pOut.WriteByte((byte)_algorithm);

                    pOut.WriteObject((BcpgObject)_key);

                    return bOut.ToArray();
                }
            }
        }