用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创建环境变量
  2. Windows 7系统下安装Visual Studio 2015/2017/2019
  3. MySQL快速插入大量数据——使用LOAD DATA语句
  4. VBS文件拖拽的个数限制(无法执行 – 参数列表过长)
  5. 批处理技术内幕:IF命令

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

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

留下回复