Share via


PasswordDeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) Méthode

Définition

Dérive une clé de chiffrement de l'objet PasswordDeriveBytes.

public:
 cli::array <System::Byte> ^ CryptDeriveKey(System::String ^ algname, System::String ^ alghashname, int keySize, cli::array <System::Byte> ^ rgbIV);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public byte[] CryptDeriveKey (string? algname, string? alghashname, int keySize, byte[] rgbIV);
public byte[] CryptDeriveKey (string algname, string alghashname, int keySize, byte[] rgbIV);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.CryptDeriveKey : string * string * int * byte[] -> byte[]
member this.CryptDeriveKey : string * string * int * byte[] -> byte[]
Public Function CryptDeriveKey (algname As String, alghashname As String, keySize As Integer, rgbIV As Byte()) As Byte()

Paramètres

algname
String

Nom de l'algorithme pour lequel la clé doit être dérivée.

alghashname
String

Nom de l'algorithme de hachage à utiliser pour dériver la clé.

keySize
Int32

Taille de la clé à dériver, en bits.

rgbIV
Byte[]

Vecteur d'initialisation (IV) à utiliser pour dériver la clé.

Retours

Byte[]

Clé dérivée.

Attributs

Exceptions

Le paramètre keySize est incorrect.

- ou -

Le fournisseur de services de chiffrement ne peut pas être acquis.

- ou -

Le paramètre algname n'est pas un nom d'algorithme valide.

- ou -

Le paramètre alghashname n'est pas un nom d'algorithme de hachage valide.

Exemples

Cet exemple de code fait partie d’un exemple plus grand fourni pour la PasswordDeriveBytes classe .

// Create the key and set it to the Key property
// of the TripleDESCryptoServiceProvider object.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
 cryptoDESProvider->Key = passwordDeriveBytes->CryptDeriveKey
     ("TripleDES", "SHA1", 192, cryptoDESProvider->IV);

// Create the key and set it to the Key property
// of the TripleDESCryptoServiceProvider object.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV);

' Create the key and set it to the Key property
' of the TripleDESCryptoServiceProvider object.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV)

Remarques

Cette fonction est un wrapper pour la fonction d’API Crypto CryptDeriveKey(), et est destinée à offrir une interopérabilité avec les applications utilisant l’API Crypto.

Si le keySize paramètre est défini sur 0 bits, la taille de clé par défaut pour l’algorithme spécifié est utilisée.

S’applique à

Voir aussi