用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. GetDeviceCaps函数的困惑
  2. 用C语言实现PHP的base64_decode函数
  3. 人人网状态及评论导出工具
  4. 文件夹拒绝访问且文件夹显示为空的解决方法
  5. eXeScope注册码算法

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

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

留下回复