Results 1 to 3 of 3

Thread: Byte Array to Hex String

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Byte Array to Hex String

    Is there a built in way to convert a Byte Array to a Hex String or do I have to write my own?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Byte Array to Hex String

    Depending on the type of string encoding you want to use, you can use a member of the System.Text namespace to do your encoding. You can use a UTF7Encoding for Unicode strings, or the AsciiEncoding for Ascii strings.

    Here is a simple ascii example:
    vb Code:
    1. Dim objByte As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes("MyString")
    2. MessageBox.Show(System.Text.ASCIIEncoding.ASCII.GetString(objByte))


    EDIT: Oops I read that wrong, you wanted a byte array to a hex string, not a normal string. Let me see what else I can find.
    Last edited by Negative0; Sep 20th, 2007 at 12:40 PM.

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Byte Array to Hex String

    To output it as a hex string, you can use the Bitconverter:

    vb Code:
    1. MessageBox.Show(BitConverter.ToString(objByte))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width