it should convert it as 0377777706676F6F676C6503636F6D00

0377777706676F6F676C6503636F6D00 is the hex dump representation of the name part of the assembled DNS packet:

0020 0a 02 80 22 00 35 00 28 96 13 f4 3b 01 00 00 01 ...".5.( ...; +.... 0030 00 00 00 00 00 00 03 77 77 77 06 67 6f 6f 67 6c .......w ww.g +oogl 0040 65 03 63 6f 6d 00 00 01 00 01 e.com... ..

The above dump lines correspond to the the plaintext tree parts shown in the middle frame of the wireshark window:

Answer RRs: 0 Additional RRs: 0 V Queries V www.google.com: type A, class IN Name: www.google.com Type: A (Host address) Class: IN (0x0001)

So, as you see, the name is encoded in that packet as you require, as it is sent to the DNS server. Encoding that beforehand doesn't make sense. I guess you are having an XY problem. What are you trying to do, with what results?

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: How to convert the domain name format data into hexadecimal format? by shmem
in thread How to convert the domain name format data into hexadecimal format? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.