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

備註

如需此 API 的詳細資訊,請參閱 RSACryptoServiceProvider 的補充 API 備註

建構函式

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)
Decrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

使用指定的填補模式解密輸入資料。

(繼承來源 RSA)
Decrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding)

使用指定的填補模式解密輸入資料。

(繼承來源 RSA)
DecryptValue(Byte[])
已淘汰.

目前版本中不支援這個方法。

DecryptValue(Byte[])
已淘汰.

在衍生類別中覆寫時,使用私密金鑰解密輸入資料。

(繼承來源 RSA)
Dispose()

釋放 AsymmetricAlgorithm 類別目前的執行個體所使用的全部資源。

(繼承來源 AsymmetricAlgorithm)
Dispose(Boolean)

釋放 AsymmetricAlgorithm 類別所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 AsymmetricAlgorithm)
Encrypt(Byte[], Boolean)

RSA 演算法加密資料。

Encrypt(Byte[], RSAEncryptionPadding)

使用 RSA 演算法搭配指定的填補來加密資料。

Encrypt(Byte[], RSAEncryptionPadding)

使用指定的填補模式在衍生類別中覆寫,加密輸入的資料。

(繼承來源 RSA)
Encrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

使用指定的填補模式加密輸入資料。

(繼承來源 RSA)
Encrypt(ReadOnlySpan<Byte>, Span<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)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。

(繼承來源 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters)

使用以位元組為基礎的密碼 PEM 編碼,以 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)
GetMaxOutputSize()

取得 RSA 作業可產生的最大位元元組數目。

(繼承來源 RSA)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName)

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為位元組陣列中的指定部分計算出雜湊值。

(繼承來源 RSA)
HashData(Stream, HashAlgorithmName)

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為指定的二進位資料流計算出雜湊值。

(繼承來源 RSA)
ImportCspBlob(Byte[])

匯入代表 RSA 金鑰資訊的 Blob。

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

(繼承來源 RSA)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

使用 Char 型密碼解密之後,從 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(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

計算指定資料的雜湊值並進行簽署。

(繼承來源 RSA)
SignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

使用指定的演算法計算所提供數據的哈希,並使用目前的密鑰簽署哈希,並將簽章寫入提供的緩衝區。

(繼承來源 RSA)
SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的資料流計算出雜湊值。

(繼承來源 RSA)
SignData(Stream, Object)

使用指定的雜湊演算法,來為指定的輸入資料流計算出雜湊值,並簽署產生的雜湊值。

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

針對指定雜湊值的簽章,使用指定的填補來計算。

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

在衍生類別中覆寫時,針對指定雜湊值的簽章,使用指定的填補來計算。

(繼承來源 RSA)
SignHash(Byte[], String)

計算指定的雜湊值簽章。

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

針對指定雜湊值的簽章,使用指定的填補來計算。

(繼承來源 RSA)
SignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

使用目前的金鑰簽署哈希,並將簽章寫入提供的緩衝區。

(繼承來源 RSA)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
ToXmlString(Boolean)

建立並傳回 XML 字串,其中包含目前 RSA 物件的金鑰。

(繼承來源 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)

使用 Char 型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。

(繼承來源 RSA)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

嘗試使用以位元組為基礎的密碼 PEM 編碼,以 PKCS#8 EncryptedPrivateKeyInfo 格式導出目前的密鑰。

(繼承來源 AsymmetricAlgorithm)
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)

適用於

另請參閱