Help with WinHex API Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Advanced Features » Help with WinHex API « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Alberto Vílchez Carpio
Username: albertov

Registered: N/A
Posted on Monday, May 18, 2009 - 12:20:   

Hi I am Alberto from Spain,

I would like to make a program that directly with a file like input give me back the file´s hash code: Checksum 32, CRC-16, CRC-32, MD5 and SHA-1.

I need to recover the hash algorithm from WinHex using Visual Basic 2005. Have the WinHex API some function to recover Checksum 32, CRC-16, CRC-32, MD5 and SHA-1 hash into a string variable in Visual Basic 2005?

I need this to create a table from a file in Word with the result of the hash algorithm.

Thanks.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Monday, May 18, 2009 - 13:20:   

No, the WinHex API does not have such a function.
Top of pagePrevious messageNext messageBottom of page Link to this message

René Axnix
Username: reax

Registered: N/A
Posted on Monday, May 18, 2009 - 16:25:   

search for "slavasoft" & "quickhash"
Top of pagePrevious messageNext messageBottom of page Link to this message

Alberto Vílchez Carpio
Username: albertov

Registered: N/A
Posted on Tuesday, May 19, 2009 - 12:17:   

Hello!

I see that exists a command called "CalcHashEx HashType MyVariable" using WinHex scripts but the value stored in the variable is different that the message box show it.

Example:

CalcHashEx SHA-1 var
'Show 711383A59FDA05336FD2CCF70C8059D1523EB41A in the screen

messagebox var
'Show others characters

I try to calculate de hash and put the result into a variable to write in other file with de following format:

SHA-1: 711383A59FDA05336FD2CCF70C8059D1523EB41A

Thanks.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Tuesday, May 19, 2009 - 12:41:   

Yes, with a WinHex script it is possible.

> messagebox var
> 'Show others characters

That's because the hash value is stored in binary in the variable, not in Hex ASCII.

You could write the hash values into a file with the "Write" command (before and after use "NextObj" to switch between source data and output file), and finally convert the output file from binary to Hex ASCII with the "Convert Binary HexASCII" command.
Top of pagePrevious messageNext messageBottom of page Link to this message

Alberto Vílchez Carpio
Username: albertov

Registered: N/A
Posted on Wednesday, May 20, 2009 - 10:22:   

Thanks for your help Stefan and René.

Now I make this script:

-------- CODE -----------
CalcHash SHA-1 var
Open "C:\checksum.txt"

Write var
Convert Binary HexASCII

Save
CloseAll
-------------------------

This script save the hash into checksum.txt file but the value stored is different to Tools|Compute Hash command.

Using Tools|Compute Hash
------------------------

CS32: 000001A3
CRC16: C223
CRC32: 90B39A3A
MD5: 311020666A5776C57D265ACE682DC46D
SHA-1: 1267EA54D8DC193B000D4A86487C7D38B7A55E43

With the script
------------------------

CS32: A301000000
CRC16: 23C200
CRC32: 3A9AB39000
MD5: 311020666A5776C57D265ACE682DC46D00
SHA-1: 1267EA54D8DC193B000D4A86487C7D38B7A55E4300

What I´m doing wrong in the script? I would like to get the following format in the file:

000001A3-C223-90B39A3A-311020666A5776C57D265ACE682DC46D-1267EA54D8DC193B000D4A86487C7D38B7A55E43

Thanks.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Wednesday, May 20, 2009 - 11:02:   

You are not doing anything wrong. Short hash types such as CS32 and CRC32 are commonly displayed as byte-wise reversed, probably because they are like integer numbers that are stored in little-endian byte order by Intel and related processors. Tools | Compute Hash and all other programs that I know reverse the byte order of short hash types. When you save the raw binary hash value to a file, the order is not reversed.

Add Your Message Here
Post:
Username: Posting Information:
Only registered users may post messages here, i.e. you need to have an account.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:
Forum operated by X-Ways Software Technology AG.