BinaryCheckSum

Returns the MD5, SHA1, or SHA256 digest (fingerprint) or simple CRC of a binary buffer.

Syntax:

BinaryCheckSum( handle, request )

Parameters:

(i) handle: handle of buffer.

(i) request: specifies the type of digest or CRC to generate. See below.

Returns:

(s) a hex-value string.

 

request

Specifies the type of digest or CRC to generate, and can be one of the following values:

 

Request

Meaning

Return String Format (x=hex character)

0

MD5 digest

"xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"

1

16-bit CRC

"xxxx"

2

32-bit CRC

"xxxxxxxx"

3

SHA1 *

"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

4

SHA256 *

"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

 

* Requires Windows Vista/2008 or newer

 

Note: this function supports binary buffers up to 4GBs when used with 64-bit WinBatch.

Example:


fn="C:\testfile.txt"
fs=FileSize(fn)
bb=BinaryAlloc(fs)
BinaryRead(bb,fn)
MD5=BinaryChecksum(bb,0)
BinaryFree(bb)
Message("MD5 Fingerprint",StrCat(fn,@CRLF,MD5))
See Also:

BinaryAlloc, BinaryFree