The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: lamer on April 12, 2005, 05:58:00 PM

Title: Lamer's question #1 - byte array to hexadecimal string
Post by: lamer on April 12, 2005, 05:58:00 PM
Hi all!
I am absolutely lamer in assembler, so my question is "lamery" as well.
How can I convert a byte array to hexadecimal string?
In other words, I create hash and want it to appear as "normal" hexadecimal string,not as scribble.
I have found nothing in all FAQs. Any little example or link!.. :(
Thank you in advance.
Title: Re: Lamer's question #1 - byte array to hexadecimal string
Post by: Vortex on April 12, 2005, 06:32:33 PM
Did you check the dw2hex function from masm32.lib?

Quote
This function was contributed to MASM32 by "f0dder", a student from Silkborg in Denmark.

dw2hex proc source:DWORD, lpBuffer:DWORD

Description
dw2hex converts a DWORD value to an ascii hex string.

Parameters


1. source The DWORD value to convert

   2. lpBuffer The address of the buffer to receive the ascii hex string


Return Value

There is no return value.

Comments

The buffer for the result needs to be 8 bytes long plus one byte for the terminator so for alignment, make the buffer 12 bytes long.
Title: Re: Lamer's question #1 - byte array to hexadecimal string
Post by: lamer on April 12, 2005, 06:49:04 PM
Thanks, Vortex, I will try it.