UDF > Crypt >


_Crypt_DeriveKey

Cr�e une cl� � partir d'un algorithme et d'un mot de passe

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

Param�tres

$vPassword Mot de passe � utiliser
$iAlgID ID de chiffrement de l'algorithme � utiliser avec la cl�. Voir Remarque
$iHashPasswordID [optionnel] ID de l'algorithme de hachage qui utilise le mot de passe. Voir Remarques.

Valeur de retour

Succ�s: Retourne un handle vers une cl� de chiffrement.
�chec: D�finit @error <> 0.
@error: 10+ - Impossible de cr�er l'objet de hachage
20+ - Impossible de hacher le mot de passe
30+ - Impossible de g�n�rer la cl�
1000+ - Echec de _Crypt_Startup()

Remarque

La cl� doit �tre d�truite avec _Crypt_DestroyKey().

    Encryption Algorithm ID

$iAlgID Value Type Key-length
$CALG_AES_128 0x0000660e Cipher block chaining 128 bits
$CALG_AES_192 0x0000660f Cipher block chaining 192 bits
$CALG_AES_256 0x00006610 Cipher block chaining 256 bits
$CALG_DES 0x00006601 Cipher block chaining 56 bits
$CALG_3DES 0x00006603 Cipher block chaining 168 bits
$CALG_RC2 0x00006602 Block encryption algorithm 128 bits
$CALG_RC4 0x00006801 Stream encryption algorithm 128 bits
$CALG_USERKEY 0

    Hashing Algorithm ID

$iHashPasswordID Value Type Key-length
$CALG_MD2 0x00008001 Hashing algorithm 128-bit
$CALG_MD4 0x00008002 Hashing algorithm 128-bit
$CALG_MD5 0x00008003 Hashing algorithm 128-bit
$CALG_SHA1 0x00008004 Hashing algorithm 160-bit
$CALG_SHA_256 0x0000800c Hashing algorithm 256-bit
$CALG_SHA_384 0x0000800d Hashing algorithm 384-bit
$CALG_SHA_512 0x0000800e Hashing algorithm 512-bit

En relation

_Crypt_DecryptData, _Crypt_DecryptFile, _Crypt_DestroyKey, _Crypt_EncryptData, _Crypt_EncryptFile

Voir aussi

Recherchez CryptDeriveKey dans la biblioth�que MSDN.

Exemple

#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) ; D�clare un mot de passe sous forme de cha�ne et l'algorithme pour cr�er une cl� de chiffrement.

    For $vText In $aStringsToEncrypt
        $sOutput &= $vText & @TAB & " = " & _Crypt_EncryptData($vText, $hKey, $CALG_USERKEY) & @CRLF ; Chiffre le texte avec la cl� de chiffrement.
    Next

    MsgBox($MB_SYSTEMMODAL, "Donn�es chiffr�es", $sOutput)

    _Crypt_DestroyKey($hKey) ; D�truit la cl� de chiffrement.
EndFunc   ;==>Example