I was planning to write it myself, but it would be hard to get rid of complicated algorithm descriptions. Forget it. If there are ready-made COM Object calls, why bother with algorithms? Just use them directly. If the following example code prompts that an object cannot be created, you need to download the CAPICOM component and register it.
Copy codeThe Code is 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 should be noted that the VBS string is Unicode encoded. For example, the above string "Demon" in the memory is in hexadecimal 4400 6500 6D00 6F00 6E00, these Hash algorithms only care about the binary value of the data, the binary value of the same string of different encoding is different, this is the calculated value and PHP (PHP default encoding is UTF-8) the reason why the sha1 ("Demon") value of is different. For more CAPICOM usage, refer to the MSDN reference document.
The following is a program that uses VBS to verify the SHA1 and MD5 values of the file. Drag the file to VBS. The disadvantage is that it cannot process too many files.
Software and vbs package download http://xiazai.jb51.net/201101/tools/capicom_dc_sdk_jb51.rar
Original article: http://demon.tw/programming/vbs-sha1-md5.html