ファイルのハッシュ値(SHA256、MD5)を取得するモジュールです
call FileHash.uws
path = "C:\path\to\uwscpro5302.exe"
msgbox(FileHash.SHA256(path))
msgbox(FileHash.MD5(path))module FileHash
function SHA256(path)
fileb = getFileBytes(path)
hashb = getHashBytes(fileb, PROGID_SHA256)
result = getHex(hashb)
fend
function MD5(path)
fileb = getFileBytes(path)
hashb = getHashBytes(fileb, PROGID_MD5)
result = getHex(hashb)
fend
function getFileBytes(path)
with createoleobj("ADODB.Stream")
.Open()
.Type = 1
.LoadFromFile("D:\jtakahashi\Downloads\開発\uwsc\uwscpro5302.exe")
result = .Read()
.Close()
endwith
fend
function getHashBytes(bytes, progid)
with createoleobj(progid)
.ComputeHash_2(bytes)
result = .Hash
.Clear()
endwith
fend
function getHex(bytes)
with createoleobj("MSXML2.DOMDocument")
with .createElement("tmp")
.dataType = "bin.hex"
.nodeTypedValue = bytes
result = .text
endwith
endwith
fend
const PROGID_SHA256 = "System.Security.Cryptography.SHA256Managed"
const PROGID_MD5 = "System.Security.Cryptography.MD5CryptoServiceProvider"
endmodule