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

Definicja

Uzyskuje klucz kryptograficzny z PasswordDeriveBytes obiektu .

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

Parametry

algname
String

Nazwa algorytmu, dla którego ma pochodzić klucz.

alghashname
String

Nazwa algorytmu skrótu do użycia w celu uzyskania klucza.

keySize
Int32

Rozmiar klucza, w bitach, do uzyskania.

rgbIV
Byte[]

Wektor inicjowania (IV) używany do uzyskiwania klucza.

Zwraca

Byte[]

Klucz pochodny.

Wyjątki

Parametr keySize jest niepoprawny.

— lub —

Nie można uzyskać dostawcy usług kryptograficznych (CSP).

— lub —

Parametr algname nie jest prawidłową nazwą algorytmu.

— lub —

Parametr alghashname nie jest prawidłową nazwą algorytmu skrótu.

Przykłady

Ten przykład kodu jest częścią większego przykładu udostępnionego dla klasy 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.
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)

Uwagi

Ta funkcja jest otoką funkcji CryptDeriveKey() interfejsu API kryptograficznego i ma oferować współdziałanie z aplikacjami przy użyciu interfejsu API kryptograficznego.

keySize Jeśli parametr ma wartość 0 bitów, używany jest domyślny rozmiar klucza dla określonego algorytmu.

Dotyczy

Zobacz też