• Welcome to Valhalla Legends Archive.
 

Decoding Hex

Started by Fr0z3N, May 30, 2003, 10:40 PM

Previous topic - Next topic

Fr0z3N

I know how to turn text into hex but i don't know how to decode it so i can read it. Would anyone mind giving me any idea's or just give me the source for it?

Spht

#1
Quote from: Fr0z3N on May 30, 2003, 10:40 PM
I know how to turn text into hex but i don't know how to decode it so i can read it. Would anyone mind giving me any idea's or just give me the source for it?

Well, for converting text to hex, you looped through each character, converting it to hex and storing it in a variable and returning the result. So to undo that, loop through every second character, and convert the hex to ASCII of the next two characters following each loop using the Chr function and specifying that it's hexidecimal that you want to convert to ASCII.

Edit - I see someone else has beaten me to replying. Now I'm sure he'll just grab that code snippet and hop over my post.

Fr0z3N

Being lazy, I use his coding but to learn I read your post Spht.

Fr0z3N

Dim strText As String, sBuf As String, i As Long

For i = 1 To Len(strText) Step 2
sBuf = Chr("&H" & Mid$(strText, i, 2))
Next i

Isn't working any ideas why?

Soul Taker

#4

You have:
sBuf = Chr("&H" & Mid$(strText, i, 2))
The example here has:
sBuf = sBuf & chr("&H" & mid$(strText, i, 2))

You forgot to prepend the buffer to the character being converted.

Fr0z3N

I tryed it with the sBuf first but that didn't work so i just forgot to change it back.
niether ways work.