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

Definición

Deriva una clave criptográfica a partir del objeto 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()

Parámetros

algname
String

Nombre del algoritmo para el que se va a derivar la clave.

alghashname
String

Nombre del algoritmo hash que se va a usar para derivar la clave.

keySize
Int32

Tamaño de la clave, en bits, que se va a derivar.

rgbIV
Byte[]

Vector de inicialización (IV) que se va a usar para derivar la clave.

Devoluciones

Byte[]

Clave derivada.

Atributos

Excepciones

El parámetro keySize no es correcto.

o bien

No se puede adquirir el proveedor de servicios criptográficos (CSP).

O bien

El parámetro algname no es un nombre de algoritmo válido.

o bien

El parámetro alghashname no es un nombre de algoritmo hash válido.

Ejemplos

Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase PasswordDeriveBytes.

// 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)

Comentarios

Esta función es un contenedor para la función crypto API CryptDeriveKey() y está pensada para ofrecer interoperabilidad con aplicaciones mediante crypto API.

Si el keySize parámetro se establece en 0 bits, se usa el tamaño de clave predeterminado para el algoritmo especificado.

Se aplica a

Consulte también