广州明生医药有限公司


用VBS模拟实现PHP的sha1_file函数效果代码

网络编程 用VBS模拟实现PHP的sha1_file函数效果代码 06-22

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
原文:http://demon.tw/programming/vbs-php-sha1_file.html

VBS中通过调用CAPICOM对象实现SHA1&MD5加密
本来打算自己写的,但是看到复杂的算法描述就知难而退了。算了吧,有现成的COM对象调用,又何必去关心算法呢,直接拿来使用就行了。如果下面的

用VBS获取Unix时间戳的函数代码
VBS中没有类似C标准库中的time函数,怎么获取Unix时间戳呢?乍一看很简单:FunctionUnixTime()UnixTime=DateDiff("s","01/01/197000:00:00",Now())EndFunction一个很想当然的

VBS模拟POST上传文件的代码
'XMLUploadClassClassXMLUploadPrivatexmlHttpPrivateobjTempPrivateadTypeBinary,adTypeTextPrivatestrCharset,strBoundaryPrivateSubClass_Initialize()adTypeBinary=1adTypeText=2SetxmlHttp=CreateObject("Msxml


编辑:广州明生医药有限公司

标签:算法,函数,对象,代码,时间