帮助文档里有
#include "ACN_HASH.au3"
Local $msgstr = "notepad2.exe" & @CRLF
$msgstr &= "Md5: " & Check_Md5(@ScriptDir & "\notepad2.exe") & @CRLF
$msgstr &= "Sha1: " & Check_Sha1(@ScriptDir & "\notepad2.exe") & @CRLF
$msgstr &= "Crc32: " & Check_Crc32(@ScriptDir & "\notepad2.exe")
MsgBox(0, "", $msgstr)
Func Check_Md5($FileName)
Local $BufferSize = 0x20000
Local $FileHandle = FileOpen($Filename, 16)
Local $MD5CTX = _MD5Init()
Local $i
For $i = 1 To Ceiling(FileGetSize($FileName) / $BufferSize)
_MD5Input($MD5CTX, FileRead($FileHandle, $BufferSize))
Next
Local $Hash = _MD5Result($MD5CTX)
FileClose($FileHandle)
Return $Hash
EndFunc
Func Check_Sha1($FileName)
Local $BufferSize = 0x20000
Local $FileHandle = FileOpen($FileName, 16)
Local $SHA1CTX = _SHA1Init()
Local $i
For $i = 1 To Ceiling(FileGetSize($FileName) / $BufferSize)
_SHA1Input($SHA1CTX, FileRead($FileHandle, $BufferSize))
Next
Local $Hash = _SHA1Result($SHA1CTX)
FileClose($FileHandle)
Return $Hash
EndFunc
Func Check_Crc32($FileName)
Local $BufferSize = 0x20000
Local $FileHandle = FileOpen($Filename, 16)
Local $CRC32 = 0
Local $i
For $i = 1 To Ceiling(FileGetSize($Filename) / $BufferSize)
$CRC32 = _CRC32(FileRead($FileHandle, $BufferSize), BitNot($CRC32))
Next
FileClose($FileHandle)
Return Hex($CRC32, 8)
EndFunc
|