PasswordDeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) Metodo

Definizione

Deriva una chiave crittografica dall'oggetto PasswordDeriveBytes .

public:
 cli::array <System::Byte> ^ CryptDeriveKey(System::String ^ algname, System::String ^ alghashname, int keySize, cli::array <System::Byte> ^ rgbIV);
public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV);
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()

Parametri

algname
String

Nome dell'algoritmo per il quale derivare la chiave.

alghashname
String

Nome dell'algoritmo hash da usare per derivare la chiave.

keySize
Int32

Dimensione della chiave, espressa in bit, da derivare.

rgbIV
Byte[]

Vettore di inizializzazione (IV) da usare per derivare la chiave.

Valori restituiti

Byte[]

Chiave derivata.

Eccezioni

Il keySize parametro non è corretto.

oppure

Non è possibile acquisire il provider di servizi di crittografia.The cryptographic service provider (CSP) cannot be acquired.

oppure

Il algname parametro non è un nome di algoritmo valido.

oppure

Il alghashname parametro non è un nome di algoritmo hash valido.

Esempio

Questo esempio di codice fa parte di un esempio più ampio fornito per 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.
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)

Commenti

Questa funzione è un wrapper per la funzione crypto API CryptDeriveKey() ed è progettata per offrire l'interoperabilità con le applicazioni che usano l'API Crypto.

Se il keySize parametro è impostato su 0 bit, viene usata la dimensione della chiave predefinita per l'algoritmo specificato.

Si applica a

Vedi anche