AsymmetricAlgorithm.Create Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Skapar ett kryptografiskt objekt som används för att utföra den asymmetriska algoritmen.
Överlagringar
| Name | Description |
|---|---|
| Create() |
Skapar ett standardkryptografiskt objekt som används för att utföra den asymmetriska algoritmen. |
| Create(String) |
Skapar en instans av den angivna implementeringen av en asymmetrisk algoritm. |
Create()
Skapar ett standardkryptografiskt objekt som används för att utföra den asymmetriska algoritmen.
public:
static System::Security::Cryptography::AsymmetricAlgorithm ^ Create();
public static System.Security.Cryptography.AsymmetricAlgorithm Create();
static member Create : unit -> System.Security.Cryptography.AsymmetricAlgorithm
Public Shared Function Create () As AsymmetricAlgorithm
Returer
En ny RSACryptoServiceProvider instans, såvida inte standardinställningarna har ändrats med <cryptoClass-elementet>.
Undantag
.NET Core 2.0 – 3.1 och .NET 5 och senare: I samtliga fall.
Kommentarer
Den här metoden är föråldrad i .NET 5 och senare versioner.
Example
Följande kodexempel visar hur du implementerar Create metoden i en utökad klass. Det här kodexemplet är en del av ett större exempel för AsymmetricAlgorithm klassen.
// 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
Se även
Gäller för
Create(String)
Skapar en instans av den angivna implementeringen av en asymmetrisk algoritm.
public:
static System::Security::Cryptography::AsymmetricAlgorithm ^ Create(System::String ^ algName);
public static System.Security.Cryptography.AsymmetricAlgorithm Create(string algName);
static member Create : string -> System.Security.Cryptography.AsymmetricAlgorithm
Public Shared Function Create (algName As String) As AsymmetricAlgorithm
Parametrar
- algName
- String
Den asymmetriska algoritmimplementering som ska användas. I följande tabell visas giltiga värden för parametern algName och de algoritmer som de mappas till.
| Parametervärde | Implementerar |
|---|---|
| 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 |
Returer
En ny instans av den angivna asymmetriska algoritmimplementeringen.
Exempel
Följande kodexempel visar hur du implementerar Create metoden i en utökad klass. Det här kodexemplet är en del av ett större exempel för AsymmetricAlgorithm klassen.
// 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