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

Definizione

Deriva una chiave di crittografia dall'oggetto 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()

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 in bit della chiave da derivare.

rgbIV
Byte[]

Vettore di inizializzazione da usare per derivare la chiave.

Restituisce

Byte[]

Chiave derivata.

Attributi

Eccezioni

Il parametro keySize non è corretto.

-oppure-

Non è possibile acquisire il provider del servizio di crittografia (CSP).

-oppure-

Il parametro algname non corrisponde a un nome di algoritmo valido.

-oppure-

Il parametro alghashname non corrisponde a 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.
 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)

Commenti

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

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

Si applica a

Vedi anche