AsymmetricAlgorithm.Create Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Создает криптографический объект, используемый для выполнения алгоритма асимметричного шифрования.
Перегрузки
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
Возвращаемое значение
Новый экземпляр RSACryptoServiceProvider, если параметры по умолчанию не были изменены с помощью элемента <cryptoClass>.
- Атрибуты
Исключения
.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)
Создает экземпляр заданной реализации алгоритма асимметричного шифрования.
public:
static System::Security::Cryptography::AsymmetricAlgorithm ^ Create(System::String ^ algName);
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
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