Last active
October 22, 2018 01:00
-
-
Save stuncloud/fe46f58620bae665a5a3defccaa3757f to your computer and use it in GitHub Desktop.
ファイルのハッシュ値(SHA256、MD5)を取得するモジュールです
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call FileHash.uws | |
path = "C:\path\to\uwscpro5302.exe" | |
msgbox(FileHash.SHA256(path)) | |
msgbox(FileHash.MD5(path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(path) | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment