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

Definicja

Wyprowadza klucz kryptograficzny z PasswordDeriveBytes obiektu.

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

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) do użycia w celu uzyskania klucza.

Zwraca

Byte[]

Klucz pochodny.

Atrybuty

Wyjątki

Parametr keySize jest nieprawidłowy.

-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 podanego PasswordDeriveBytes dla klasy.

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

Uwagi

Ta funkcja jest otoką funkcji CryptDeriveKey() interfejsu API kryptograficznego i jest przeznaczona do oferowania współdziałania z aplikacjami przy użyciu interfejsu API kryptograficznego.

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

Dotyczy

Zobacz też