VBS to implement SHA1&MD5 encryption by calling the CAPICOM object _vbs

Source: Internet
Author: User
Tags md5 md5 encryption sha1
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

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.