Function Reference


Decrypts data using the supplied key

#include <Crypt.au3>
_Crypt_DecryptData ( $vData, $vCryptKey, $iAlgID [, $bFinal = True] )


$vData Data to decrypt
$vCryptKey Password or handle to a key if the CALG_USERKEY flag is specified
$iAlgID The algorithm to use
$bFinal [optional] False if this is only a segment of the full data

Return Value

Success: a binary string containing decrypted data.
Failure: sets the @error flag to non-zero.
@error: 100+ - Cannot create key
20 - Failed to decrypt data


The decrypted data is always returned as a binary string even if the encrypted data is in fact a string (cast with BinaryToString()).


_Crypt_DeriveKey, _Crypt_EncryptData

See Also

Search CryptDecrypt in MSDN Library.


#include <Crypt.au3>
#include <MsgBoxConstants.au3>


Func Example()
    Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
    Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be encrypted.

    Local $bEncrypted = _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4) ; Encrypt the data using the generic password string.

    $bEncrypted = _Crypt_DecryptData($bEncrypted, $sUserKey, $CALG_RC4) ; Decrypt the data using the generic password string. The return value is a binary string.
    MsgBox($MB_SYSTEMMODAL, "Decrypted data", BinaryToString($bEncrypted)) ; Convert the binary string using BinaryToString to display the initial data we encrypted.
EndFunc   ;==>Example