Crée une clé à partir d'un algorithme et d'un mot de passe
#include <Crypt.au3>
_Crypt_DeriveKey ( $vPassword, $iAlgID [, $iHashPasswordID = $CALG_MD5] )
$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. |
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() |
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 |
$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 |
_Crypt_DecryptData, _Crypt_DecryptFile, _Crypt_DestroyKey, _Crypt_EncryptData, _Crypt_EncryptFile
Recherchez CryptDeriveKey dans la bibliothèque MSDN.
#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