CryptoConfig.CreateFromName 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立指定的密碼物件的新實例。
多載
| 名稱 | Description |
|---|---|
| CreateFromName(String) |
建立指定的密碼物件的新實例。 |
| CreateFromName(String, Object[]) |
建立指定密碼物件的新實例,並使用指定的參數。 |
CreateFromName(String)
建立指定的密碼物件的新實例。
public:
static System::Object ^ CreateFromName(System::String ^ name);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
public static object? CreateFromName(string name);
public static object CreateFromName(string name);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")>]
static member CreateFromName : string -> obj
static member CreateFromName : string -> obj
Public Shared Function CreateFromName (name As String) As Object
參數
- name
- String
用來建立實例的密碼物件名稱。
傳回
指定密碼物件的新實例。
- 屬性
例外狀況
參數 name 為 null。
參數所描述 name 的演算法在啟用聯邦資訊處理標準(FIPS)模式下使用,但不相容於 FIPS。
範例
以下程式碼範例示範如何呼叫 CreateFromName 該方法來建立新的 SHA-1 提供者。 此程式碼範例是本類別更大範例 CryptoConfig 的一部分。
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
SHA1CryptoServiceProvider SHA1alg =
(SHA1CryptoServiceProvider)CryptoConfig.CreateFromName("SHA1");
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
Dim SHA1alg As SHA1CryptoServiceProvider
SHA1alg = CType( _
cryptoConfig.CreateFromName("SHA1"), SHA1CryptoServiceProvider)
備註
關於此類別所識別的簡單名稱列表,請參見 CryptoConfig。
另請參閱
適用於
CreateFromName(String, Object[])
建立指定密碼物件的新實例,並使用指定的參數。
public:
static System::Object ^ CreateFromName(System::String ^ name, ... cli::array <System::Object ^> ^ args);
public:
static System::Object ^ CreateFromName(System::String ^ name, cli::array <System::Object ^> ^ args);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
public static object? CreateFromName(string name, params object?[]? args);
public static object CreateFromName(string name, params object[] args);
public static object CreateFromName(string name, object[] args);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")>]
static member CreateFromName : string * obj[] -> obj
static member CreateFromName : string * obj[] -> obj
Public Shared Function CreateFromName (name As String, ParamArray args As Object()) As Object
Public Shared Function CreateFromName (name As String, args As Object()) As Object
參數
- name
- String
用來建立實例的密碼物件名稱。
- args
- Object[]
用於建立指定密碼物件的參數。
傳回
指定密碼物件的新實例。
- 屬性
例外狀況
參數 name 為 null。
參數所描述 name 的演算法在啟用聯邦資訊處理標準(FIPS)模式下使用,但不相容於 FIPS。
範例
以下程式碼範例示範如何呼叫 CreateFromName 該方法,以初始化存取 TestContainer 金鑰容器的新 RSA 提供者實例。 此程式碼範例是本類別更大範例 CryptoConfig 的一部分。
CspParameters parameters = new CspParameters();
parameters.KeyContainerName = "TestContainer";
Object[] argsArray = new Object[] {parameters};
// Instantiate the RSA provider instance accessing the TestContainer
// key container.
RSA rsa = (RSA)
CryptoConfig.CreateFromName("RSA",argsArray);
Dim parameters As New CspParameters
parameters.KeyContainerName = "TestContainer"
Dim argsArray() = New Object() {parameters}
' Instantiate the RSA provider instance accessing the key container
' TestContainer.
Dim rsa As RSA = RSA.Create()
rsa = CType(cryptoConfig.CreateFromName( _
"RSA", argsArray), _
RSA)
備註
關於此類別所識別的簡單名稱列表,請參見 CryptoConfig。