AsymmetricAlgorithm.Create Metoda

Definicja

Tworzy obiekt kryptograficzny używany do wykonywania algorytmu asymetrycznego.

Przeciążenia

Create()
Przestarzałe.
Przestarzałe.

Tworzy domyślny obiekt kryptograficzny używany do wykonywania algorytmu asymetrycznego.

Create(String)
Przestarzałe.

Tworzy wystąpienie określonej implementacji algorytmu asymetrycznego.

Create()

Źródło:
AsymmetricAlgorithm.cs
Źródło:
AsymmetricAlgorithm.cs
Źródło:
AsymmetricAlgorithm.cs

Przestroga

The default implementation of this cryptography algorithm is not supported

Przestroga

The default implementation of this cryptography algorithm is not supported.

Tworzy domyślny obiekt kryptograficzny używany do wykonywania algorytmu asymetrycznego.

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

Zwraca

Nowe RSACryptoServiceProvider wystąpienie, chyba że ustawienia domyślne zostały zmienione za pomocą <elementu cryptoClass>.

Atrybuty

Wyjątki

.NET Core 2.0 — 3.1 i .NET 5 i nowsze: we wszystkich przypadkach.

Uwagi

Ta metoda jest przestarzała na platformie .NET 5 i nowszych wersjach.

Przykład

W poniższym przykładzie kodu pokazano, jak zaimplementować metodę Create w klasie rozszerzonej. Ten przykład kodu jest częścią większego przykładu podanego AsymmetricAlgorithm dla klasy.

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

Zobacz też

Dotyczy

Create(String)

Źródło:
AsymmetricAlgorithm.cs
Źródło:
AsymmetricAlgorithm.cs
Źródło:
AsymmetricAlgorithm.cs

Przestroga

Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.

Tworzy wystąpienie określonej implementacji algorytmu asymetrycznego.

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

Parametry

algName
String

Implementacja algorytmu asymetrycznego do użycia. W poniższej tabeli przedstawiono prawidłowe wartości parametru algName i algorytmy, do których są mapowe.

Wartość parametru Implementuje
System.Security.Cryptography.AsymmetricAlgorithmAsymmetricAlgorithm
RSARSA
System.Security.Cryptography.RSARSA
DSADSA
System.Security.Cryptography.DSADSA
EcdsaECDsa
EcdsacngECDsaCng
System.Security.Cryptography.ECDsaCngECDsaCng
ECDHECDiffieHellman
EcdiffiehellmanECDiffieHellman
EcdiffiehellmancngECDiffieHellmanCng
System.Security.Cryptography.ECDiffieHellmanCngECDiffieHellmanCng

Zwraca

Nowe wystąpienie określonej implementacji algorytmu asymetrycznego.

Atrybuty

Przykłady

W poniższym przykładzie kodu pokazano, jak zaimplementować metodę Create w klasie rozszerzonej. Ten przykład kodu jest częścią większego przykładu podanego AsymmetricAlgorithm dla klasy.

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

Zobacz też

Dotyczy