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

Definição

Deriva uma chave criptográfica a partir do PasswordDeriveBytes objeto.

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

Parâmetros

algname
String

O nome do algoritmo para o qual se deve derivar a chave.

alghashname
String

O nome do algoritmo de hash a usar para derivar a chave.

keySize
Int32

O tamanho da chave, em bits, a derivar.

rgbIV
Byte[]

O vetor de inicialização (IV) a usar para obter a chave.

Devoluções

Byte[]

A chave derivada.

Exceções

O keySize parâmetro está incorreto.

-ou-

O fornecedor de serviços criptográficos (CSP) não pode ser adquirido.

-ou-

O algname parâmetro não é um nome válido de algoritmo.

-ou-

O alghashname parâmetro não é um nome válido de algoritmo de hash.

Exemplos

Este exemplo de código faz parte de um exemplo maior fornecido para a 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)

Observações

Esta função é um wrapper para a função Crypto API CryptDeriveKey(), e destina-se a oferecer interoperabilidade com aplicações que utilizam a Crypto API.

Se o keySize parâmetro for definido para 0 bits, é utilizado o tamanho padrão da chave para o algoritmo especificado.

Aplica-se a

Ver também