Function Reference


_Crypt_DeriveKey

Creates a key from algorithm and password

#include <Crypt.au3>
_Crypt_DeriveKey ( $vPassword, $iAlgID [, $iHashAlgID = $CALG_MD5] )

Parameters

$vPassword Password to use
$iAlgID Encryption ID of algorithm to be used with the key
$iHashAlgID [optional] Id of the algo to hash the password with

Return Value

Success: a handle to a cryptographic key.
Failure: -1 and sets the @error flag to non-zero.
@error: 10 - Failed to create hash object
20 - Failed to hash password
30 - Failed to generate key

Remarks

The key needs to be destroyed with _Crypt_DestroyKey().

Related

_Crypt_DecryptData, _Crypt_DecryptFile, _Crypt_DestroyKey, _Crypt_EncryptData, _Crypt_EncryptFile

See Also

Search CryptDeriveKey in MSDN Library.

Example

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

Example()

Func Example()
    Local $aStringsToEncrypt[6] = ["AutoIt", "SciTE", "Crypt", ".au3", 42, "42"]
    Local $sOutput = ""

    Local $hKey = _Crypt_DeriveKey("CryptPassword", $CALG_RC4) ; Declare a password string and algorithm to create a cryptographic key.

    For $iWord In $aStringsToEncrypt
        $sOutput &= $iWord & @TAB & " = " & _Crypt_EncryptData($iWord, $hKey, $CALG_USERKEY) & @CRLF ; Encrypt the text with the cryptographic key.
    Next

    MsgBox($MB_SYSTEMMODAL, "Encrypted data", $sOutput)

    _Crypt_DestroyKey($hKey) ; Destroy the cryptographic key.
EndFunc   ;==>Example