网站建设行业文章6
当前位置: 首页 -> 企业资讯 -> 行业文章 -> 利用WindowsInstaller.Installer 对象计算文件 MD5 hash 值
鸿大千秋新闻顶部侧栏



利用WindowsInstaller.Installer 对象计算文件 MD5 hash 值



Option Explicit

Dim wi
Dim file
Dim file_size
DIm file_attributes
Dim file_version
Dim file_hash

Set wi = CreateObject(“WindowsInstaller.Installer”)
file = “C:/WINDOWS/explorer.exe”
file_size = wi.FileSize(file)
file_attributes = wi.FileAttributes(file)
file_version = wi.FileVersion(file)
file_hash = GetFileHash(file)

Set wi = Nothing

MsgBox “File: ” & file & vbCrLf &_
        “Size: ” & file_size & vbCrLf &_
        “Attributes: ” & file_attributes & vbCrLf &_
        “Version: ” & file_version & vbCrLf &_
        “MD5: ” & file_hash

Function GetFileHash(file_name)
        Dim file_hash
        Dim hash_value
        Dim i

        Set file_hash = wi.FileHash(file_name, 0)

        hash_value = “”

        For i = 1 To file_hash.FieldCount
                hash_value = hash_value & BigEndianHex(file_hash.IntegerData(i))
        Next

        GetFileHash = hash_value

        Set file_hash = Nothing
End Function

Function BigEndianHex(int)
        Dim result
        Dim b1, b2, b3, b4

        result = Hex(int)
        b1 = Mid(result, 7, 2)
        b2 = Mid(result, 5, 2)
        b3 = Mid(result, 3, 2)
        b4 = Mid(result, 1, 2)

        BigEndianHex = b1 & b2 & b3 & b4
End Function

 参考http://hi.baidu.com/umu618/blog/item/d2772e1f6e0c0bd2a686697f.html

本文摘自UMU由网络安全攻防研究室(www.91ri.org) 信息安全小组收集整理.



鸿大千秋网站建设团队敬上







Copyright © hongdaChiaki. All Rights Reserved. 鸿大千秋 版权所有


联系方式:
地址: 深圳市南山区招商街道沿山社区沿山路43号创业壹号大楼A栋107室
邮箱:service@hongdaqianqiu.com
备案号:粤ICP备15078875号