示例#1
0
        public void WriteBase16String()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteBase16String(new byte[] { 1, 2, 3 });
            writer.WriteBase16String(new byte[] { 1, 2, 3 }, appendSpace: false);
            Assert.AreEqual("010203 010203", text.ToString());
        }
示例#2
0
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            writer.WriteByte((byte)HashAlgorithm);
            writer.WriteByte((byte)Flags);
            writer.WriteUInt16(Iterations);

            if (Salt == null || Salt.Length == 0)
            {
                writer.WriteString("-");
            }
            else
            {
                writer.WriteBase16String(Salt);
            }

            writer.WriteString(Base32.ExtendedHex.Encode(NextHashedOwnerName, padding: false).ToLowerInvariant());

            bool next = false;

            foreach (var type in Types)
            {
                if (next)
                {
                    writer.WriteSpace();
                }
                writer.WriteDnsType(type, appendSpace: false);
                next = true;
            }
        }
示例#3
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(KeyTag);
     writer.WriteByte((byte)Algorithm);
     writer.WriteByte((byte)HashAlgorithm);
     writer.WriteBase16String(Digest, appendSpace: false);
 }
示例#4
0
        /// <summary>
        ///   Write the textual representation of the data that is specific to
        ///   the resource record.
        /// </summary>
        /// <param name="writer">
        ///   The destination for the resource record's data.
        /// </param>
        /// <remarks>
        ///   Derived classes should implement this method.
        ///   <para>
        ///   By default, this will write the hex encoding of
        ///   the <see cref="GetData">RDATA</see> preceeded by
        ///   "\#" and the number integer bytes.
        ///   </para>
        /// </remarks>
        public virtual void WriteData(PresentationWriter writer)
        {
            var rdata   = GetData();
            var hasData = rdata.Length > 0;

            writer.WriteStringUnencoded("\\#");
            writer.WriteUInt32((uint)rdata.Length, appendSpace: hasData);
            if (hasData)
            {
                writer.WriteBase16String(rdata, appendSpace: false);
            }
        }
示例#5
0
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            writer.WriteByte((byte)HashAlgorithm);
            writer.WriteByte((byte)Flags);
            writer.WriteUInt16(Iterations);

            if (Salt == null || Salt.Length == 0)
            {
                writer.WriteString("-");
            }
            else
            {
                writer.WriteBase16String(Salt, appendSpace: false);
            }
        }