RSACryptoServiceProvider 类

定义

使用加密服务提供程序 (CSP) 提供的 RSA 算法的实现执行非对称加密和解密。 此类不能被继承。

public ref class RSACryptoServiceProvider sealed : System::Security::Cryptography::RSA, System::Security::Cryptography::ICspAsymmetricAlgorithm
public ref class RSACryptoServiceProvider sealed : System::Security::Cryptography::RSA
public sealed class RSACryptoServiceProvider : System.Security.Cryptography.RSA, System.Security.Cryptography.ICspAsymmetricAlgorithm
public sealed class RSACryptoServiceProvider : System.Security.Cryptography.RSA
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class RSACryptoServiceProvider : System.Security.Cryptography.RSA, System.Security.Cryptography.ICspAsymmetricAlgorithm
type RSACryptoServiceProvider = class
    inherit RSA
    interface ICspAsymmetricAlgorithm
type RSACryptoServiceProvider = class
    inherit RSA
[<System.Runtime.InteropServices.ComVisible(true)>]
type RSACryptoServiceProvider = class
    inherit RSA
    interface ICspAsymmetricAlgorithm
Public NotInheritable Class RSACryptoServiceProvider
Inherits RSA
Implements ICspAsymmetricAlgorithm
Public NotInheritable Class RSACryptoServiceProvider
Inherits RSA
继承
RSACryptoServiceProvider
属性
实现

示例

下面的代码示例使用 RSACryptoServiceProvider 类将字符串加密为字节数组,然后将字节解密回字符串。

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
array<Byte>^ RSAEncrypt( array<Byte>^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
{
   try
   {
      
      //Create a new instance of RSACryptoServiceProvider.
      RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
      
      //Import the RSA Key information. This only needs
      //toinclude the public key information.
      RSA->ImportParameters( RSAKeyInfo );
      
      //Encrypt the passed byte array and specify OAEP padding.  
      //OAEP padding is only available on Microsoft Windows XP or
      //later.  

      array<Byte>^encryptedData = RSA->Encrypt( DataToEncrypt, DoOAEPPadding );
      delete RSA;
      return encryptedData;
   }
   //Catch and display a CryptographicException  
   //to the console.
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( e->Message );
      return nullptr;
   }

}

array<Byte>^ RSADecrypt( array<Byte>^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
{
   try
   {
      
      //Create a new instance of RSACryptoServiceProvider.
      RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
      
      //Import the RSA Key information. This needs
      //to include the private key information.
      RSA->ImportParameters( RSAKeyInfo );
      
      //Decrypt the passed byte array and specify OAEP padding.  
      //OAEP padding is only available on Microsoft Windows XP or
      //later.  
      
      array<Byte>^decryptedData = RSA->Decrypt( DataToDecrypt, DoOAEPPadding );
      delete RSA;
      return decryptedData;
   }
   //Catch and display a CryptographicException  
   //to the console.
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( e );
      return nullptr;
   }

}

int main()
{
   try
   {
      
      //Create a UnicodeEncoder to convert between byte array and string.
      UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding;
      
      //Create byte arrays to hold original, encrypted, and decrypted data.
      array<Byte>^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" );
      array<Byte>^encryptedData;
      array<Byte>^decryptedData;
      
      //Create a new instance of RSACryptoServiceProvider to generate
      //public and private key data.
      RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
      
      //Pass the data to ENCRYPT, the public key information 
      //(using RSACryptoServiceProvider.ExportParameters(false),
      //and a boolean flag specifying no OAEP padding.
      encryptedData = RSAEncrypt( dataToEncrypt, RSA->ExportParameters( false ), false );
      
      //Pass the data to DECRYPT, the private key information 
      //(using RSACryptoServiceProvider.ExportParameters(true),
      //and a boolean flag specifying no OAEP padding.
      decryptedData = RSADecrypt( encryptedData, RSA->ExportParameters( true ), false );
      
      //Display the decrypted plaintext to the console. 
      Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
      delete RSA;
   }
   catch ( ArgumentNullException^ ) 
   {
      
      //Catch this exception in case the encryption did
      //not succeed.
      Console::WriteLine( "Encryption failed." );
   }

}
using System;
using System.Security.Cryptography;
using System.Text;

class RSACSPSample
{

    static void Main()
    {
        try
        {
            //Create a UnicodeEncoder to convert between byte array and string.
            UnicodeEncoding ByteConverter = new UnicodeEncoding();

            //Create byte arrays to hold original, encrypted, and decrypted data.
            byte[] dataToEncrypt = ByteConverter.GetBytes("Data to Encrypt");
            byte[] encryptedData;
            byte[] decryptedData;

            //Create a new instance of RSACryptoServiceProvider to generate
            //public and private key data.
            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
            {

                //Pass the data to ENCRYPT, the public key information 
                //(using RSACryptoServiceProvider.ExportParameters(false),
                //and a boolean flag specifying no OAEP padding.
                encryptedData = RSAEncrypt(dataToEncrypt, RSA.ExportParameters(false), false);

                //Pass the data to DECRYPT, the private key information 
                //(using RSACryptoServiceProvider.ExportParameters(true),
                //and a boolean flag specifying no OAEP padding.
                decryptedData = RSADecrypt(encryptedData, RSA.ExportParameters(true), false);

                //Display the decrypted plaintext to the console. 
                Console.WriteLine("Decrypted plaintext: {0}", ByteConverter.GetString(decryptedData));
            }
        }
        catch (ArgumentNullException)
        {
            //Catch this exception in case the encryption did
            //not succeed.
            Console.WriteLine("Encryption failed.");
        }
    }

    public static byte[] RSAEncrypt(byte[] DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding)
    {
        try
        {
            byte[] encryptedData;
            //Create a new instance of RSACryptoServiceProvider.
            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
            {

                //Import the RSA Key information. This only needs
                //toinclude the public key information.
                RSA.ImportParameters(RSAKeyInfo);

                //Encrypt the passed byte array and specify OAEP padding.  
                //OAEP padding is only available on Microsoft Windows XP or
                //later.  
                encryptedData = RSA.Encrypt(DataToEncrypt, DoOAEPPadding);
            }
            return encryptedData;
        }
        //Catch and display a CryptographicException  
        //to the console.
        catch (CryptographicException e)
        {
            Console.WriteLine(e.Message);

            return null;
        }
    }

    public static byte[] RSADecrypt(byte[] DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding)
    {
        try
        {
            byte[] decryptedData;
            //Create a new instance of RSACryptoServiceProvider.
            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
            {
                //Import the RSA Key information. This needs
                //to include the private key information.
                RSA.ImportParameters(RSAKeyInfo);

                //Decrypt the passed byte array and specify OAEP padding.  
                //OAEP padding is only available on Microsoft Windows XP or
                //later.  
                decryptedData = RSA.Decrypt(DataToDecrypt, DoOAEPPadding);
            }
            return decryptedData;
        }
        //Catch and display a CryptographicException  
        //to the console.
        catch (CryptographicException e)
        {
            Console.WriteLine(e.ToString());

            return null;
        }
    }
}
Imports System.Security.Cryptography
Imports System.Text

 _

Class RSACSPSample


    Shared Sub Main()
        Try
            'Create a UnicodeEncoder to convert between byte array and string.
            Dim ByteConverter As New UnicodeEncoding()

            'Create byte arrays to hold original, encrypted, and decrypted data.
            Dim dataToEncrypt As Byte() = ByteConverter.GetBytes("Data to Encrypt")
            Dim encryptedData() As Byte
            Dim decryptedData() As Byte

            'Create a new instance of RSACryptoServiceProvider to generate
            'public and private key data.
            Using RSA As New RSACryptoServiceProvider

                'Pass the data to ENCRYPT, the public key information 
                '(using RSACryptoServiceProvider.ExportParameters(false),
                'and a boolean flag specifying no OAEP padding.
                encryptedData = RSAEncrypt(dataToEncrypt, RSA.ExportParameters(False), False)

                'Pass the data to DECRYPT, the private key information 
                '(using RSACryptoServiceProvider.ExportParameters(true),
                'and a boolean flag specifying no OAEP padding.
                decryptedData = RSADecrypt(encryptedData, RSA.ExportParameters(True), False)

                'Display the decrypted plaintext to the console. 
                Console.WriteLine("Decrypted plaintext: {0}", ByteConverter.GetString(decryptedData))
            End Using
        Catch e As ArgumentNullException
            'Catch this exception in case the encryption did
            'not succeed.
            Console.WriteLine("Encryption failed.")
        End Try
    End Sub


    Public Shared Function RSAEncrypt(ByVal DataToEncrypt() As Byte, ByVal RSAKeyInfo As RSAParameters, ByVal DoOAEPPadding As Boolean) As Byte()
        Try
            Dim encryptedData() As Byte
            'Create a new instance of RSACryptoServiceProvider.
            Using RSA As New RSACryptoServiceProvider

                'Import the RSA Key information. This only needs
                'toinclude the public key information.
                RSA.ImportParameters(RSAKeyInfo)

                'Encrypt the passed byte array and specify OAEP padding.  
                'OAEP padding is only available on Microsoft Windows XP or
                'later.  
                encryptedData = RSA.Encrypt(DataToEncrypt, DoOAEPPadding)
            End Using
            Return encryptedData
            'Catch and display a CryptographicException  
            'to the console.
        Catch e As CryptographicException
            Console.WriteLine(e.Message)

            Return Nothing
        End Try
    End Function


    Public Shared Function RSADecrypt(ByVal DataToDecrypt() As Byte, ByVal RSAKeyInfo As RSAParameters, ByVal DoOAEPPadding As Boolean) As Byte()
        Try
            Dim decryptedData() As Byte
            'Create a new instance of RSACryptoServiceProvider.
            Using RSA As New RSACryptoServiceProvider
                'Import the RSA Key information. This needs
                'to include the private key information.
                RSA.ImportParameters(RSAKeyInfo)

                'Decrypt the passed byte array and specify OAEP padding.  
                'OAEP padding is only available on Microsoft Windows XP or
                'later.  
                decryptedData = RSA.Decrypt(DataToDecrypt, DoOAEPPadding)
                'Catch and display a CryptographicException  
                'to the console.
            End Using
            Return decryptedData
        Catch e As CryptographicException
            Console.WriteLine(e.ToString())

            Return Nothing
        End Try
    End Function
End Class

下面的代码示例将使用 RSACryptoServiceProvider 对象创建的密钥信息导出到 RSAParameters 对象中。

try
{
   //Create a new RSACryptoServiceProvider Object*.
   RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
   
   //Export the key information to an RSAParameters object.
   //Pass false to export the public key information or pass
   //true to export public and private key information.
   RSAParameters RSAParams = RSA->ExportParameters( false );
}
catch ( CryptographicException^ e ) 
{
   //Catch this exception in case the encryption did
   //not succeed.
   Console::WriteLine( e->Message );
}
try
{
    //Create a new RSACryptoServiceProvider object.
    using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
    {

        //Export the key information to an RSAParameters object.
        //Pass false to export the public key information or pass
        //true to export public and private key information.
        RSAParameters RSAParams = RSA.ExportParameters(false);
    }
}
catch (CryptographicException e)
{
    //Catch this exception in case the encryption did
    //not succeed.
    Console.WriteLine(e.Message);
}
Try

    'Create a new RSACryptoServiceProvider object. 
    Dim RSA As New RSACryptoServiceProvider()

    'Export the key information to an RSAParameters object.
    'Pass false to export the public key information or pass
    'true to export public and private key information.
    Dim RSAParams As RSAParameters = RSA.ExportParameters(False)


Catch e As CryptographicException
    'Catch this exception in case the encryption did
    'not succeed.
    Console.WriteLine(e.Message)
End Try

注解

这是默认实现 。RSA

如果安装了 Microsoft 增强加密提供程序,则 RSACryptoServiceProvider 支持从 384 位到 16384 位的密钥大小(增量为 8 位)。 如果安装了 Microsoft 基础加密提供程序,它支持从 384 位到 512 位的密钥大小(增量为 8 位)。

有效密钥大小取决于实例使用的 RSACryptoServiceProvider 加密服务提供程序 (CSP) 。 对于Windows 8.1之前的 Windows 版本,Windows CSP 的密钥大小为 384 到 16384 位,Windows 8.1的密钥大小为 512 到 16384 位。 有关详细信息,请参阅 Windows 文档中的 CryptGenKey 函数。

与 Microsoft 加密 API (CAPI) 互操作

与非托管 CAPI 中的 RSA 实现不同,类 RSACryptoServiceProvider 在加密后和解密之前反转加密字节数组的顺序。 默认情况下,类加密 RSACryptoServiceProvider 的数据不能由 CAPI CryptDecrypt 函数解密,CAPI CryptEncrypt 方法加密的数据不能由 RSACryptoServiceProvider 类解密。

如果在 API 之间互操作时不补偿反向顺序,则 RSACryptoServiceProvider 类会引发一个 CryptographicException

若要与 CAPI 互操作,必须在加密数据与其他 API 互操作之前手动反转加密字节的顺序。 可以通过调用 Array.Reverse 方法轻松反转托管字节数组的顺序。

构造函数

RSACryptoServiceProvider()

使用随机的密钥对初始化 RSACryptoServiceProvider 类的新实例。

RSACryptoServiceProvider(CspParameters)

使用指定的参数初始化 RSACryptoServiceProvider 类的新实例。

RSACryptoServiceProvider(Int32)

使用指定密钥大小的随机密钥对来初始化 RSACryptoServiceProvider 类的新实例。

RSACryptoServiceProvider(Int32, CspParameters)

使用指定的密钥大小和参数初始化 RSACryptoServiceProvider 类的新实例。

字段

KeySizeValue

表示非对称算法所用密钥模块的大小(以位为单位)。

(继承自 AsymmetricAlgorithm)
LegalKeySizesValue

指定非对称算法支持的密钥大小。

(继承自 AsymmetricAlgorithm)

属性

CspKeyContainerInfo

获取描述有关加密密钥对的附加信息的 CspKeyContainerInfo 对象。

KeyExchangeAlgorithm

获取可用于 RSA 的此实现的密钥交换算法的名称。

KeyExchangeAlgorithm

获取可用于 RSA 的此实现的密钥交换算法的名称。

(继承自 RSA)
KeySize

获取当前密钥的大小。

LegalKeySizes

获取非对称算法支持的密钥大小。

LegalKeySizes

获取非对称算法支持的密钥大小。

(继承自 AsymmetricAlgorithm)
PersistKeyInCsp

获取或设置一个值,该值指示是否应在加密服务提供程序 (CSP) 中保留此密钥。

PublicOnly

获取一个值,该值指示 RSACryptoServiceProvider 对象是否仅包含公钥。

SignatureAlgorithm

获取可用于此 RSA 的实现的签名算法的名称。

SignatureAlgorithm

获取可用于此 RSA 的实现的签名算法的名称。

(继承自 RSA)
UseMachineKeyStore

获取或设置一个值,该值指示是否应在计算机的密钥存储而不是用户配置文件存储中保留密钥。

方法

Clear()

释放 AsymmetricAlgorithm 类使用的所有资源。

(继承自 AsymmetricAlgorithm)
Decrypt(Byte[], Boolean)

使用 RSA 算法加密数据。

Decrypt(Byte[], RSAEncryptionPadding)

使用指定填充对以前通过 RSA 算法加密的数据进行解密。

Decrypt(Byte[], RSAEncryptionPadding)

在派生类中被重写时,使用指定的填充模式来解密输入数据。

(继承自 RSA)
DecryptValue(Byte[])

当前版本不支持此方法。

DecryptValue(Byte[])

当在派生类中重写时,使用私钥解密输入数据。

(继承自 RSA)
Dispose()

释放 AsymmetricAlgorithm 类的当前实例所使用的所有资源。

(继承自 AsymmetricAlgorithm)
Dispose(Boolean)

释放 AsymmetricAlgorithm 类使用的非托管资源,并可以选择释放托管资源。

(继承自 AsymmetricAlgorithm)
Encrypt(Byte[], Boolean)

使用 RSA 算法加密数据。

Encrypt(Byte[], RSAEncryptionPadding)

使用指定的填充,借助 RSA 算法对数据加密。

Encrypt(Byte[], RSAEncryptionPadding)

在派生类中被重写时,使用指定的填充模式加密输入数据。

(继承自 RSA)
EncryptValue(Byte[])

当前版本不支持此方法。

EncryptValue(Byte[])

当在派生类中重写时,使用公钥加密输入数据。

(继承自 RSA)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
ExportCspBlob(Boolean)

导出包含与 RSACryptoServiceProvider 对象关联的密钥信息的 blob。

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式导出当前密钥。

(继承自 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式导出当前密钥。

(继承自 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters)

使用基于字符的密码(PEM 编码)导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportParameters(Boolean)

导出 RSAParameters

ExportPkcs8PrivateKey()

以 PKCS#8 PrivateKeyInfo 格式导出当前密钥。

(继承自 AsymmetricAlgorithm)
ExportPkcs8PrivateKeyPem()

导出 PKCS#8 PrivateKeyInfo 格式的当前密钥,PEM 编码。

(继承自 AsymmetricAlgorithm)
ExportRSAPrivateKey()

以 PKCS#1 RSAPrivateKey 格式导出当前密钥。

(继承自 RSA)
ExportRSAPrivateKeyPem()

导出 PKCS#1 RSAPrivateKey 格式的当前密钥,进行 PEM 编码。

(继承自 RSA)
ExportRSAPublicKey()

以 PKCS#1 RSAPublicKey 格式导出当前密钥的公钥部分。

(继承自 RSA)
ExportRSAPublicKeyPem()

导出 PKCS#1 RSAPublicKey 格式(PEM 编码)中当前密钥的公钥部分。

(继承自 RSA)
ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式导出当前密钥的公钥部分。

(继承自 AsymmetricAlgorithm)
ExportSubjectPublicKeyInfoPem()

导出 X.509 SubjectPublicKeyInfo 格式(PEM 编码)中当前密钥的公钥部分。

(继承自 AsymmetricAlgorithm)
Finalize()

释放该实例占用的非托管资源。

FromXmlString(String)

通过 XML 字符串中的密钥信息初始化 RSA 对象。

(继承自 RSA)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName)

在派生类中被重写时,使用指定的哈希算法计算字节数组指定部分的哈希值。

(继承自 RSA)
HashData(Stream, HashAlgorithmName)

在派生类中被重写时,使用指定的哈希算法计算指定的二进制流的哈希值。

(继承自 RSA)
ImportCspBlob(Byte[])

导入表示 RSA 密钥信息的 blob。

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

使用基于字节的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

(继承自 RSA)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用基于字符的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

(继承自 RSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

导入已加密的 RFC 7468 PEM 编码的私钥,替换此对象的密钥。

(继承自 RSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

导入已加密的 RFC 7468 PEM 编码的私钥,替换此对象的密钥。

(继承自 RSA)
ImportFromPem(ReadOnlySpan<Char>)

导入 RFC 7468 PEM 编码的密钥,替换此对象的密钥。

(继承自 RSA)
ImportParameters(RSAParameters)

导入指定的 RSAParameters

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#8 PrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

(继承自 RSA)
ImportRSAPrivateKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#1 RSAPrivateKey 结构中导入公共/私有密钥对,以便替换此对象的密钥。

(继承自 RSA)
ImportRSAPublicKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#1 RSAPublicKey 结构中导入公钥,以便替换此对象的密钥。

(继承自 RSA)
ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

解密后,从 X.509 SubjectPublicKeyInfo 结构中导入公钥,以替换此对象的密钥。

(继承自 RSA)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节的哈希值,并对生产的哈希值进行签名。

(继承自 RSA)
SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节数组部分的哈希值并签名生成的哈希值。

(继承自 RSA)
SignData(Byte[], Int32, Int32, Object)

使用指定的哈希算法计算指定字节数组子集的哈希值,并对生成的哈希值进行签名。

SignData(Byte[], Object)

使用指定的哈希算法计算指定字节数组的哈希值,并对生成的哈希值进行签名。

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定流的哈希值并签名生成的哈希值。

(继承自 RSA)
SignData(Stream, Object)

使用指定的哈希算法计算指定输入流的哈希值,并对生成的哈希值进行签名。

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的填充计算指定的哈希值的签名。

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

在派生类中重写时,使用指定的填充来计算指定的哈希值的签名。

(继承自 RSA)
SignHash(Byte[], String)

计算指定哈希值的签名。

ToString()

返回表示当前对象的字符串。

(继承自 Object)
ToXmlString(Boolean)

创建并返回包含当前 RSA 对象的密钥的 XML 字符串。

(继承自 RSA)
TryDecrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

尝试使用指定填充模式对输入数据进行解密,然后将结果写入到提供的缓冲区中。

(继承自 RSA)
TryEncrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

尝试使用指定的填充模式将输入数据加密存入提供的缓冲区中。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导入所提供的缓冲区。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

使用基于字符的密码 PEM 编码导出 PKCS#8 EncryptedPrivateKeyInfo 格式中的当前密钥。

(继承自 AsymmetricAlgorithm)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

尝试以 PKCS#8 PrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

(继承自 RSA)
TryExportPkcs8PrivateKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#8 PrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 AsymmetricAlgorithm)
TryExportRSAPrivateKey(Span<Byte>, Int32)

尝试以 PKCS#1 RSAPrivateKey 格式将当前密钥导入所提供的缓冲区。

(继承自 RSA)
TryExportRSAPrivateKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#1 RSAPrivateKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportRSAPublicKey(Span<Byte>, Int32)

尝试以 PKCS#1 RSAPublicKey 格式将当前密钥导入所提供的缓冲区。

(继承自 RSA)
TryExportRSAPublicKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#1 RSAPublicKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

尝试以 X.509 SubjectPublicKeyInfo 格式将当前密钥导出到所提供的缓冲区。

(继承自 RSA)
TryExportSubjectPublicKeyInfoPem(Span<Char>, Int32)

尝试将 PEM 编码的 X.509 SubjectPublicKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 AsymmetricAlgorithm)
TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

尝试使用指定算法计算提供的数据的哈希值,然后将结果写入提供的缓冲区中。

(继承自 RSA)
TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32)

尝试使用指定的算法对提供的数据进行哈希处理,并使用当前密钥对哈希进行签名,从而将签名写入所提供的缓冲区中。

(继承自 RSA)
TrySignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32)

尝试使用当前密钥对哈希进行签名,从而将签名写入到提供的缓冲区中。

(继承自 RSA)
VerifyData(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充方式计算指定数据的哈希值,然后将其与提供的签名进行比较来验证数字签名是否有效。

(继承自 RSA)
VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充模式计算字节数组某部分中数据的哈希值,并将其与所提供的签名进行比较,以此验证数字签名是否有效。

(继承自 RSA)
VerifyData(Byte[], Object, Byte[])

通过使用提供的公钥计算签名中的哈希值,然后将其与提供的数据的哈希值进行比较,从而验证数字签名是否有效。

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充方式计算指定数据的哈希值,然后将其与提供的签名进行比较来验证数字签名是否有效。

(继承自 RSA)
VerifyData(Stream, Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充方式计算指定流的哈希值,然后将其与提供的签名进行比较来验证数字签名是否有效。

(继承自 RSA)
VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充确定签名中的哈希值,并将其与提供的哈希值进行比较,以此验证数字签名是否有效。

VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充方式计算签名中的哈希值,然后将其与提供的哈希值进行比较来验证数字签名是否有效。

(继承自 RSA)
VerifyHash(Byte[], String, Byte[])

通过使用提供的公钥计算签名中的哈希值,然后将其与提供的哈希值进行比较来验证数字签名是否有效。

VerifyHash(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充方式计算签名中的哈希值,然后将其与提供的哈希值进行比较来验证数字签名是否有效。

(继承自 RSA)

显式接口实现

IDisposable.Dispose()

此 API 支持产品基础结构,不能在代码中直接使用。

有关此成员的说明,请参见 Dispose()

(继承自 AsymmetricAlgorithm)

适用于

另请参阅