用VBS实现PHP的md5_file函数

标签: , , , ,

Function md5_file(filename, raw_output)
    Dim HashedData, Utility, Stream
    Set HashedData = CreateObject("CAPICOM.HashedData")
    Set Utility = CreateObject("CAPICOM.Utilities")
    Set Stream = CreateObject("ADODB.Stream")
    HashedData.Algorithm = 3
    Stream.Type = 1
    Stream.Open
    Stream.LoadFromFile filename
    Do Until Stream.EOS
        HashedData.Hash Stream.Read(1024)
    Loop
    If raw_output Then
        md5_file = Utility.HexToBinary(HashedData.Value)
    Else
        md5_file = HashedData.Value
    End If
End Function

参考链接:HashedData Object

赞赏

微信赞赏支付宝赞赏

随机文章:

  1. VBS中LoadPicture函数的正确用法
  2. VBS的一个BUG
  3. VBS模拟POST上传文件
  4. neg eax sbb eax, eax
  5. 再谈Msxml2.XMLHTTP、Msxml2.ServerXMLHTTP与缓存

一条评论 发表在“用VBS实现PHP的md5_file函数”上

  1. […] 曾经写过一篇《用VBS实现PHP的md5_file函数》,里面给出的 md5_file 函数可以用来计算文件的 MD5 hash 值。 […]

利用 WindowsInstaller.Installer 对象计算文件 MD5 hash 值 | Demon's Blog 留下回复