AsymmetricAlgorithm.Create Método

Definición

Crea un objeto criptográfico que se usa para realizar el algoritmo asimétrico.

Sobrecargas

Nombre Description
Create()

Crea un objeto criptográfico predeterminado que se usa para realizar el algoritmo asimétrico.

Create(String)

Crea una instancia de la implementación especificada de un algoritmo asimétrico.

Create()

Crea un objeto criptográfico predeterminado que se usa para realizar el algoritmo asimétrico.

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

Devoluciones

RSACryptoServiceProvider Nueva instancia, a menos que se haya cambiado la configuración predeterminada con el <elemento cryptoClass>.

Excepciones

.NET Core 2.0 - 3.1 y .NET 5 y versiones posteriores: en todos los casos.

Comentarios

Este método está obsoleto en .NET 5 y versiones posteriores.

Ejemplo

En el ejemplo de código siguiente se muestra cómo implementar el Create método en una clase extendida. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la AsymmetricAlgorithm clase .

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

Consulte también

Se aplica a

Create(String)

Crea una instancia de la implementación especificada de un algoritmo asimétrico.

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

Parámetros

algName
String

Implementación del algoritmo asimétrico que se va a usar. En la tabla siguiente se muestran los valores válidos para el algName parámetro y los algoritmos a los que se asignan.

Valor del parámetro Implementaciones
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

Devoluciones

Nueva instancia de la implementación del algoritmo asimétrico especificado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo implementar el Create método en una clase extendida. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la AsymmetricAlgorithm clase .

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

Consulte también

Se aplica a