Update 30 August:- more complete dual 64/32 bit include files (no external libraries required)
-
GetHash function:
include \masm32\MasmBasic\MasmBasic.inc
Init
Let esi=FileRead$("\Masm32\qEditor.exe")
.if GetHash(esi, LastFileSize, sha) ; FileRead$ sets LastFileSize, also for binary files
PrintLine "The SHA of qEditor.exe is ", Tb$, Hex$(xmm0), " ", Hex$(ecx)
.else
PrintLine "Hashing failed: ", Err$()
.endif
void GetHash(esi, LastFileSize)
mov ecx, edx ; fifth word returned in edx
Print "Fast MD5 of qEditor.exe is ", Tb$, Hex$(xmm0), CrLf$
GetHashRev=1 ; use official MD5 byte order
.if GetHash(FileRead$("\Masm32\qEditor.exe")) ; MD5, len of string will be calculated
PrintLine "qEditor, byte order MD5 specs: ", Tb$, Hex$(xmm0)
.endif
EndOfCode- returns success (1) or failure (0) in eax
- four dwords are returned in xmm0
- in case of SHA, the fifth dword will be in edx
- results can be displayed as a
Hex$(xmm0), plus
Hex$(edx) for SHA. The byte order will be reversed, compared to
online hash calculators. You may use
GetHashRev=1 to follow the MD5 specs, but more code will be generated
- with only one para, GetHash calculates the length; this is meaningful only for text files