Originally intended to write their own, but see the complexity of the algorithm described on the shrink. Forget it, there are ready-made COM object calls, why to care about the algorithm, directly to use on the line. If the following example code prompts you not to create an object, you need to download the CAPICOM component and register it.
Copy Code code as follows:
Const CAPICOM_HASH_ALGORITHM_MD2 = 1
Const CAPICOM_HASH_ALGORITHM_MD4 = 2
Const CAPICOM_HASH_ALGORITHM_MD5 = 3
Const CAPICOM_HASH_ALGORITHM_SHA1 = 0
Const capicom_hash_algorithm_sha_256 = 4
Const capicom_hash_algorithm_sha_384 = 5
Const capicom_hash_algorithm_sha_512 = 6
Dim Hasheddata
Set Hasheddata = CreateObject ("CAPICOM. Hasheddata ")
Hasheddata.algorithm = CAPICOM_HASH_ALGORITHM_SHA1
Hasheddata.hash "Demon"
WScript.Echo Hasheddata.value
It is necessary to point out that the string of VBS is UNICODE encoded, for example, the string "Demon" in memory in hexadecimal is 4400 6500 6d00 6f00 6E00, these hash algorithms only care about the binary value of the data, the binary value of the same string with different encodings is not the same , which is why the value calculated is different from the SHA1 ("Demon") of PHP (PHP's default encoding is UTF-8). For more CAPICOM use, consult the MSDN reference documentation yourself.
Here is a program that I write with the VBS checksum file SHA1 and MD5 value, drag the file to the VBS, the disadvantage is that can not handle too large files.
Software and VBS package download Http://xiazai.jb51.net/201101/tools/capicom_dc_sdk_jb51.rar
Original: http://demon.tw/programming/vbs-sha1-md5.html