Hack Forums
[.NET] [Help] Hex Editor, Organize Hex using RichTextBox [Help] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [Help] Hex Editor, Organize Hex using RichTextBox [Help] (/showthread.php?tid=2034445)



[Help] Hex Editor, Organize Hex using RichTextBox [Help] - smasherx74 - Dec 21, 2011

I'm trying to organize the Hexadecimals of a file into how normal hex editors look.

Here is the code im using to show the file's hex in the richtextbox.
Code
Dim myFile As String = OFD.FileName
        Dim myBytes As Byte() =
My.Computer.FileSystem.ReadAllBytes(myFile)
        Dim Temp As New System.Text.StringBuilder()
        For Each myByte As Byte In myBytes
            Temp.Append(myByte.ToString("X2"))
        Next
        RichTextBox1.Text = Temp.ToString()

Here is what it looks like and heres what I want it too look like
[img]http://localhostr.com/file/UwjOEHT/tmpBDE.jpeg[/img]
[img]http://mh-nexus.de/en/graphics/HxDShotLarge.png[/img]



* - Silicon - Dec 21, 2011

Change
Code
For Each myByte As Byte In myBytes
    Temp.Append(myByte.ToString("X2"))
To
Code
Dim inc as Integer = 0
For Each myByte As Byte In myBytes
    Temp.Append(myByte.ToString("X2") + " ")
    If inc Mod 16 = 0 Then Temp.Append(Chr(13))
    inc = inc + 1
Next myByte

I think that works (very basically). I'm a C# coder. Also don't forget to change the textbox font to Courier New.


* - CyNecx - Dec 21, 2011

you can use hexbox it'S a simple .... that you can use ...
http://sourceforge.net/projects/hexbox/

~BlueC0der