AsymmetricAlgorithm.Create 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立用來執行非對稱演算法的密碼編譯物件。
多載
Create() |
已淘汰.
已淘汰.
建立用來執行非對稱演算法的預設密碼編譯物件。 |
Create(String) |
已淘汰.
建立非對稱演算法之指定實作的執行個體。 |
Create()
警告
The default implementation of this cryptography algorithm is not supported
警告
The default implementation of this cryptography algorithm is not supported.
建立用來執行非對稱演算法的預設密碼編譯物件。
public:
static System::Security::Cryptography::AsymmetricAlgorithm ^ Create();
[System.Obsolete("The default implementation of this cryptography algorithm is not supported", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.AsymmetricAlgorithm Create ();
[System.Obsolete("The default implementation of this cryptography algorithm is not supported.", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.AsymmetricAlgorithm Create ();
public static System.Security.Cryptography.AsymmetricAlgorithm Create ();
[<System.Obsolete("The default implementation of this cryptography algorithm is not supported", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Create : unit -> System.Security.Cryptography.AsymmetricAlgorithm
[<System.Obsolete("The default implementation of this cryptography algorithm is not supported.", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Create : unit -> System.Security.Cryptography.AsymmetricAlgorithm
static member Create : unit -> System.Security.Cryptography.AsymmetricAlgorithm
Public Shared Function Create () As AsymmetricAlgorithm
傳回
除非已經使用 <cryptoClass> 項目變更預設設定,否則為新的 RSACryptoServiceProvider 執行個體。
- 屬性
例外狀況
.NET Core 2.0 - 3.1 和 .NET 5 和更新版本:在所有情況下。
備註
此方法在 .NET 5 和更新版本中已過時。
範例
下列程式代碼範例示範如何在擴充類別中實 Create 作 方法。 此程式代碼範例是提供給 類別之較大範例的 AsymmetricAlgorithm 一部分。
// The create function attempts to create a CustomCrypto
// object using the assembly name. This functionality requires
// modification of the machine.config file. Add the following
// section to the configuration element and modify the values
// of the cryptoClass to reflect what isinstalled
// in your machines GAC.
// <cryptoClass CustomCrypto="Contoso.CustomCrypto,
// CustomCrypto,
// Culture=neutral,
// PublicKeyToken=fdb9f9c4851028bf,
// Version=1.0.1448.27640" />
// <nameEntry name="Contoso.CustomCrypto"
// class="CustomCrypto" />
// <nameEntry name="CustomCrypto" class="CustomCrypto" />
public:
static CustomCrypto^ Create()
{
return Create("CustomCrypto");
}
// The create function attempts to create a CustomCrypto object using
// the assembly name. This functionality requires modification of the
// machine.config file. Add the following section to the configuration
// element and modify the values of the cryptoClass to reflect what is
// installed in your machines GAC.
// <cryptoClass CustomCrypto="Contoso.CustomCrypto,
// CustomCrypto,
// Culture=neutral,
// PublicKeyToken=fdb9f9c4851028bf,
// Version=1.0.1448.27640" />
// <nameEntry name="Contoso.CustomCrypto" class="CustomCrypto" />
// <nameEntry name="CustomCrypto" class="CustomCrypto" />
new static public CustomCrypto Create()
{
return Create("CustomCrypto");
}
' The create function attempts to create a vbCustomCrypto object using
' the assembly name. This functionality requires modification of the
' machine.config file. Add the following section to the configuration
' element and modify the values of the cryptoClass to reflect what is
' installed in your machines GAC.
' <cryptoClass vbCustomCrypto="Contoso.vbCustomCrypto,
' vbCustomCrypto,
' Culture=neutral,
' PublicKeyToken=fdb9f9c4851028bf,
' Version=1.0.1448.27640" />
' <nameEntry name="Contoso.vbCustomCrypto"
' class="vbCustomCrypto" />
' <nameEntry name="vbCustomCrypto" class="vbCustomCrypto" />
Public Shadows Function Create() As vbCustomCrypto
Return Create("vbCustomCrypto")
End Function
另請參閱
適用於
Create(String)
警告
Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.
建立非對稱演算法之指定實作的執行個體。
public:
static System::Security::Cryptography::AsymmetricAlgorithm ^ Create(System::String ^ algName);
public static System.Security.Cryptography.AsymmetricAlgorithm? Create (string algName);
[System.Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.AsymmetricAlgorithm? Create (string algName);
public static System.Security.Cryptography.AsymmetricAlgorithm Create (string algName);
static member Create : string -> System.Security.Cryptography.AsymmetricAlgorithm
[<System.Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Create : string -> System.Security.Cryptography.AsymmetricAlgorithm
Public Shared Function Create (algName As String) As AsymmetricAlgorithm
參數
- algName
- String
要使用的非對稱演算法實作。 下表顯示 algName
參數的有效值及其對應的演算法。
參數值 | 實作 |
---|---|
System.Security.Cryptography.AsymmetricAlgorithm | AsymmetricAlgorithm |
RSA | RSA |
System.Security.Cryptography.RSA | RSA |
DSA | DSA |
System.Security.Cryptography.DSA | DSA |
ECDsa | ECDsa |
ECDsaCng | ECDsaCng |
System.Security.Cryptography.ECDsaCng | ECDsaCng |
ECDH | ECDiffieHellman |
ECDiffieHellman | ECDiffieHellman |
ECDiffieHellmanCng | ECDiffieHellmanCng |
System.Security.Cryptography.ECDiffieHellmanCng | ECDiffieHellmanCng |
傳回
指定之非對稱演算法實作的新執行個體。
- 屬性
範例
下列程式代碼範例示範如何在擴充類別中實 Create 作 方法。 此程式代碼範例是提供給 類別之較大範例的 AsymmetricAlgorithm 一部分。
// The create function attempts to create a CustomCrypto object
// using the assembly name. This functionality requires
// modification of the machine.config file. Add the following
// section to the configuration element and modify the values
// of the cryptoClass to reflect what is installed
// in your machines GAC.
// <cryptoClass CustomCrypto="Contoso.CustomCrypto,
// CustomCrypto,
// Culture=neutral,
// PublicKeyToken=fdb9f9c4851028bf,
// Version=1.0.1448.27640" />
// <nameEntry name="Contoso.CustomCrypto"
// class="CustomCrypto" />
// <nameEntry name="CustomCrypto" class="CustomCrypto" />
public:
static CustomCrypto^ Create(String^ algorithmName)
{
return (CustomCrypto^)
CryptoConfig::CreateFromName(algorithmName);
}
// The create function attempts to create a CustomCrypto object using
// the assembly name. This functionality requires modification of the
// machine.config file. Add the following section to the configuration
// element and modify the values of the cryptoClass to reflect what is
// installed in your machines GAC.
// <cryptoClass CustomCrypto="Contoso.CustomCrypto,
// CustomCrypto,
// Culture=neutral,
// PublicKeyToken=fdb9f9c4851028bf,
// Version=1.0.1448.27640" />
// <nameEntry name="Contoso.CustomCrypto" class="CustomCrypto" />
// <nameEntry name="CustomCrypto" class="CustomCrypto" />
new static public CustomCrypto Create(String algorithmName)
{
return (CustomCrypto) CryptoConfig.CreateFromName(algorithmName);
}
' The create function attempts to create a vbCustomCrypto object using
' the assembly name. This functionality requires modification of the
' machine.config file. Add the following section to the configuration
' element and modify the values of the cryptoClass to reflect what is
' installed in your machines GAC.
' <cryptoClass vbCustomCrypto="Contoso.vbCustomCrypto,
' vbCustomCrypto,
' Culture=neutral,
' PublicKeyToken=fdb9f9c4851028bf,
' Version=1.0.1448.27640" />
' <nameEntry name="Contoso.vbCustomCrypto"
' class="vbCustomCrypto" />
' <nameEntry name="vbCustomCrypto" class="vbCustomCrypto" />
Public Shadows Function Create( _
ByVal algorithmName As String) As vbCustomCrypto
Return CType( _
CryptoConfig.CreateFromName(algorithmName), _
vbCustomCrypto)
End Function