In VBS, SHA1MD5 encryption is implemented by calling the CAPICOM object

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.