用VBS实现PHP的sha1_file函数

标签: , , , ,

Function sha1_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 = 0
    Stream.Type = 1
    Stream.Open
    Stream.LoadFromFile filename
    Do Until Stream.EOS
        HashedData.Hash Stream.Read(1024)
    Loop
    If raw_output Then
        sha1_file = Utility.HexToBinary(HashedData.Value)
    Else
        sha1_file = HashedData.Value
    End If
End Function

参考链接:HashedData Object

赞赏

微信赞赏支付宝赞赏

随机文章:

  1. 批处理技术内幕:重定向与管道
  2. 将WMI中的DateTime类型转换成VBS时间
  3. VBS正则表达式对象的MultiLine属性
  4. Python中的长整型(Long)乘法C源码分析
  5. Python Proxy,快速、轻量级的HTTP代理服务器

留下回复