How to use SHA-256, SHA-384, and SHA-512 hash functions in AutoIt

In the AutoIt scripting language it is possible to hash data using the _Crypt_HashData() function.

The hashing functionality is however limited to the MD2, MD4, MD5, and SHA1.
Computers running Windows XP SP3 or higher also have support for the newer SHA2 hashing functions, being SHA256, SHA384, and SHA512.

If you want to use these newer hashing functions in your applications, simply define these functions as follows:

Global Const $CALG_SHA_256 = 0x0000800c

Global Const $CALG_SHA_384 = 0x0000800d

Global Const $CALG_SHA_512 = 0x0000800e


As of then, you can use these hashing functions in your code is the same way as you were using the older hashing function. 

An example of using SHA256 in AutoIt is the following:

_Crypt_HashData($message, $CALG_SHA_256)


As explained above, the SHA2 hashing functions are supported in Windows XP SP3 or higher:
  • Windows XP with SP3 or higher:  These algorithms are supported by the Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype).
  • Windows XP with SP2, Windows XP with SP1, and Windows XP:  These algorithms are not supported.

Tags: 

Share