用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. jQuery设置ajax请求中的User-Agent
  2. EditPlus 3.30
  3. C语言标准库函数rand与多线程
  4. PowerISO 5.7 注册码
  5. VC6中使用高版本API的方法

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

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

留下回复