RSACryptoServiceProvider 類別

定義

會執行非對稱式加密和解密,方法是使用密碼編譯服務提供者 (CSP) 所提供的 RSA 演算法實作。Performs asymmetric encryption and decryption using the implementation of the RSA algorithm provided by the cryptographic service provider (CSP). 此類別無法獲得繼承。This class cannot be inherited.

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 類別,將字串加密為位元組陣列,然後將位元組解密回字串。The following code example uses the RSACryptoServiceProvider class to encrypt a string into an array of bytes and then decrypt the bytes back into a string.

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

下列程式碼範例會將使用建立的金鑰資訊匯出 RSACryptoServiceProviderRSAParameters 物件。The following code example exports the key information created using the RSACryptoServiceProvider into an RSAParameters object.

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

備註

這是的預設執行 RSAThis is the default implementation of RSA.

RSACryptoServiceProvider如果您已安裝 Microsoft 增強型密碼編譯提供者,則可支援從384位到16384位的金鑰大小(以8位遞增)。The RSACryptoServiceProvider supports key sizes from 384 bits to 16384 bits in increments of 8 bits if you have the Microsoft Enhanced Cryptographic Provider installed. 如果您已安裝 Microsoft 基礎密碼編譯提供者,它支援從384位到512位的金鑰大小(以8位遞增)。It supports key sizes from 384 bits to 512 bits in increments of 8 bits if you have the Microsoft Base Cryptographic Provider installed.

有效的金鑰大小相依于實例所使用 (CSP) 的密碼編譯服務提供者 RSACryptoServiceProviderValid key sizes are dependent on the cryptographic service provider (CSP) that is used by the RSACryptoServiceProvider instance. Windows Csp 在 windows 8.1 之前的 Windows 版本中,會啟用384至16384位的金鑰大小,以及 Windows 16384 之512至8.1 位的金鑰大小。Windows CSPs enable keys sizes of 384 to 16384 bits for Windows versions prior to Windows 8.1, and key sizes of 512 to 16384 bits for Windows 8.1. 如需詳細資訊,請參閱 Windows 檔中的 CryptGenKey 函數。For more information, see CryptGenKey function in the Windows documentation.

(CAPI) 與 Microsoft 密碼編譯 API 交互操作Interoperation with the Microsoft Cryptographic API (CAPI)

與非受控 CAPI 中的 RSA 實行不同的是, RSACryptoServiceProvider 類別會反轉加密之後和解密之前的加密位元組陣列順序。Unlike the RSA implementation in unmanaged CAPI, the RSACryptoServiceProvider class reverses the order of an encrypted array of bytes after encryption and before decryption. 根據預設,由 CAPI 函式加密的資料 RSACryptoServiceProvider 無法由 capi 函式解密 CryptDecrypt ,而由 capi 方法加密的資料 CryptEncrypt 則無法由 RSACryptoServiceProvider 類別解密。By default, data encrypted by the RSACryptoServiceProvider class cannot be decrypted by the CAPI CryptDecrypt function and data encrypted by the CAPI CryptEncrypt method cannot be decrypted by the RSACryptoServiceProvider class.

如果您未在 Api 之間進行交互操作時補償反向排序,則類別會擲回 RSACryptoServiceProvider CryptographicExceptionIf you do not compensate for the reverse ordering when interoperating between APIs, the RSACryptoServiceProvider class throws a CryptographicException.

若要與 CAPI 互通,您必須先手動反轉加密位元組的順序,加密的資料才能與另一個 API 交互操作。To interoperate with CAPI, you must manually reverse the order of encrypted bytes before the encrypted data interoperates with another API. 您可以藉由呼叫方法,輕鬆地反轉 managed 位元組陣列的順序 Array.ReverseYou can easily reverse the order of a managed byte array by calling the Array.Reverse method.

建構函式

RSACryptoServiceProvider()

使用隨機金鑰組,初始化 RSACryptoServiceProvider 類別的新執行個體。Initializes a new instance of the RSACryptoServiceProvider class with a random key pair.

RSACryptoServiceProvider(CspParameters)

使用指定的參數,初始化 RSACryptoServiceProvider 類別的新執行個體。Initializes a new instance of the RSACryptoServiceProvider class with the specified parameters.

RSACryptoServiceProvider(Int32)

使用指定金鑰大小的隨機金鑰組,以初始化 RSACryptoServiceProvider 類別的新執行個體。Initializes a new instance of the RSACryptoServiceProvider class with a random key pair of the specified key size.

RSACryptoServiceProvider(Int32, CspParameters)

使用指定的金鑰大小和參數,初始化 RSACryptoServiceProvider 類別的新執行個體。Initializes a new instance of the RSACryptoServiceProvider class with the specified key size and parameters.

欄位

KeySizeValue

表示非對稱演算法使用的金鑰模數大小,以位元為單位。Represents the size, in bits, of the key modulus used by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
LegalKeySizesValue

指定非對稱演算法所支援的金鑰大小。Specifies the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)

屬性

CspKeyContainerInfo

取得 CspKeyContainerInfo 物件,其描述密碼編譯金鑰組的其他相關資訊。Gets a CspKeyContainerInfo object that describes additional information about a cryptographic key pair.

KeyExchangeAlgorithm

取得可透過這個 RSA 實作所提供之金鑰交換演算法的名稱。Gets the name of the key exchange algorithm available with this implementation of RSA.

KeyExchangeAlgorithm

取得可透過這個 RSA 實作所提供之金鑰交換演算法的名稱。Gets the name of the key exchange algorithm available with this implementation of RSA.

(繼承來源 RSA)
KeySize

取得目前金鑰的大小。Gets the size of the current key.

LegalKeySizes

取得非對稱演算法所支援的金鑰大小。Gets the key sizes that are supported by the asymmetric algorithm.

LegalKeySizes

取得非對稱演算法所支援的金鑰大小。Gets the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
PersistKeyInCsp

取得或設定值,表示金鑰是否應該保存在密碼編譯服務提供者 (CSP) 中。Gets or sets a value indicating whether the key should be persisted in the cryptographic service provider (CSP).

PublicOnly

取得值,這個值表示 RSACryptoServiceProvider 物件是否只包含公開金鑰。Gets a value that indicates whether the RSACryptoServiceProvider object contains only a public key.

SignatureAlgorithm

取得可透過這個 RSA 實作所提供之簽章演算法的名稱。Gets the name of the signature algorithm available with this implementation of RSA.

SignatureAlgorithm

取得可透過這個 RSA 實作所提供之簽章演算法的名稱。Gets the name of the signature algorithm available with this implementation of RSA.

(繼承來源 RSA)
UseMachineKeyStore

取得或設定值,表示是否應該將金鑰保存在電腦的金鑰存放區中,而非使用者設定檔存放區。Gets or sets a value indicating whether the key should be persisted in the computer's key store instead of the user profile store.

方法

Clear()

釋放 AsymmetricAlgorithm 類別所使用的所有資源。Releases all resources used by the AsymmetricAlgorithm class.

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

RSA 演算法解密資料。Decrypts data with the RSA algorithm.

Decrypt(Byte[], RSAEncryptionPadding)

解密先前使用指定填補以 RSA 演算法加密的資料。Decrypts data that was previously encrypted with the RSA algorithm by using the specified padding.

Decrypt(Byte[], RSAEncryptionPadding)

使用指定的填補模式在衍生類別中覆寫,解密輸入的資料。When overridden in a derived class, decrypts the input data using the specified padding mode.

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

目前版本中不支援這個方法。This method is not supported in the current version.

DecryptValue(Byte[])

在衍生類別中覆寫時,使用私密金鑰解密輸入資料。When overridden in a derived class, decrypts the input data using the private key.

(繼承來源 RSA)
Dispose()

釋放 AsymmetricAlgorithm 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the AsymmetricAlgorithm class.

(繼承來源 AsymmetricAlgorithm)
Dispose(Boolean)

釋放 AsymmetricAlgorithm 類別所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the AsymmetricAlgorithm class and optionally releases the managed resources.

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

RSA 演算法加密資料。Encrypts data with the RSA algorithm.

Encrypt(Byte[], RSAEncryptionPadding)

使用 RSA 演算法搭配指定的填補來加密資料。Encrypts data with the RSA algorithm using the specified padding.

Encrypt(Byte[], RSAEncryptionPadding)

使用指定的填補模式在衍生類別中覆寫,加密輸入的資料。When overridden in a derived class, encrypts the input data using the specified padding mode.

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

目前版本中不支援這個方法。This method is not supported in the current version.

EncryptValue(Byte[])

在衍生類別中覆寫時,使用公開金鑰加密輸入資料。When overridden in a derived class, encrypts the input data using the public key.

(繼承來源 RSA)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
ExportCspBlob(Boolean)

匯出包含與 RSACryptoServiceProvider 物件相關聯金鑰資訊的 blob。Exports a blob containing the key information associated with an RSACryptoServiceProvider object.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用位元組型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

(繼承來源 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

(繼承來源 AsymmetricAlgorithm)
ExportParameters(Boolean)

匯出 RSAParametersExports the RSAParameters.

ExportPkcs8PrivateKey()

以 PKCS#8 PrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 PrivateKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
ExportRSAPrivateKey()

以 PKCS#1 RSAPrivateKey 格式匯出目前金鑰。Exports the current key in the PKCS#1 RSAPrivateKey format.

(繼承來源 RSA)
ExportRSAPublicKey()

以 PKCS#1 RSAPublicKey 格式匯出目前金鑰的公開金鑰部分。Exports the public-key portion of the current key in the PKCS#1 RSAPublicKey format.

(繼承來源 RSA)
ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式匯出目前金鑰的公開金鑰部分。Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
Finalize()

釋放此執行個體持有的未受控資源。Releases the unmanaged resources held by this instance.

FromXmlString(String)

從 XML 字串的金鑰資訊初始化 RSA 物件。Initializes an RSA object from the key information from an XML string.

(繼承來源 RSA)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

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

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為位元組陣列中的指定部分計算出雜湊值。When overridden in a derived class, computes the hash value of a specified portion of a byte array by using a specified hashing algorithm.

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

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為指定的二進位資料流計算出雜湊值。When overridden in a derived class, computes the hash value of a specified binary stream by using a specified hashing algorithm.

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

匯入代表 RSA 金鑰資訊的 Blob。Imports a blob that represents RSA key information.

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

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

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

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

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(繼承來源 RSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(繼承來源 RSA)
ImportFromPem(ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的金鑰,並取代這個物件的金鑰。Imports an RFC 7468 PEM-encoded key, replacing the keys for this object.

(繼承來源 RSA)
ImportParameters(RSAParameters)

匯入指定的 RSAParametersImports the specified RSAParameters.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密後,從 PKCS#8 PrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

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

解密後,從 PKCS#1 RSAPrivateKey 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#1 RSAPrivateKey structure after decryption, replacing the keys for this object.

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

解密後,從 PKCS#1 RSAPublicKey 結構匯入公開金鑰,以取代這個物件的金鑰。Imports the public key from a PKCS#1 RSAPublicKey structure after decryption, replacing the keys for this object.

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

解密後,從 X.509 SubjectPublicKeyInfo 結構匯入公開金鑰,以取代這個物件的金鑰。Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

(繼承來源 RSA)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的位元組陣列計算出雜湊值。Computes the hash value of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value.

(繼承來源 RSA)
SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的部分位元組陣列計算出雜湊值。Computes the hash value of a portion of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value.

(繼承來源 RSA)
SignData(Byte[], Int32, Int32, Object)

使用指定的雜湊演算法,並簽署產生的雜湊值,來為指定的位元組陣列子集計算出雜湊值。Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

SignData(Byte[], Object)

使用指定的雜湊演算法,並簽署產生的雜湊值,來為指定的位元組陣列計算出雜湊值。Computes the hash value of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的資料流計算出雜湊值。Computes the hash value of the specified stream using the specified hash algorithm and padding mode, and signs the resulting hash value.

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

使用指定的雜湊演算法,來為指定的輸入資料流計算出雜湊值,並簽署產生的雜湊值。Computes the hash value of the specified input stream using the specified hash algorithm, and signs the resulting hash value.

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

針對指定雜湊值的簽章,使用指定的填補來計算。Computes the signature for the specified hash value using the specified padding.

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

在衍生類別中覆寫時,針對指定雜湊值的簽章,使用指定的填補來計算。When overridden in a derived class, computes the signature for the specified hash value using the specified padding.

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

計算指定的雜湊值簽章。Computes the signature for the specified hash value.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
ToXmlString(Boolean)

建立並傳回 XML 字串,其中包含目前 RSA 物件的金鑰。Creates and returns an XML string containing the key of the current RSA object.

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

使用指定的填補模式,將結果寫入提供的緩衝區,以嘗試解密輸入資料。Attempts to decrypt the input data using the specified padding mode, writing the result into a provided buffer.

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

使用指定的填補模式,嘗試加密所提供緩衝區中的輸入資料。Attempts to encrypt the input data with a specified padding mode into a provided buffer.

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

使用位元組型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

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

使用 Char 型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

(繼承來源 RSA)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

嘗試以 PKCS#8 PrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 PrivateKeyInfo format into a provided buffer.

(繼承來源 RSA)
TryExportRSAPrivateKey(Span<Byte>, Int32)

嘗試以 PKCS#1 RSAPrivateKey 格式將目前金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#1 RSAPrivateKey format into a provided buffer.

(繼承來源 RSA)
TryExportRSAPublicKey(Span<Byte>, Int32)

嘗試以 PKCS#1 RSAPublicKey 格式將目前金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#1 RSAPublicKey format into a provided buffer.

(繼承來源 RSA)
TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

嘗試以 X.509 SubjectPublicKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

(繼承來源 RSA)
TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

使用指定的演算法來,將結果寫入提供的緩衝區,以嘗試計算所提供資料的雜湊。Attempts to compute the hash of the provided data by using the specified algorithm, writing the results into a provided buffer.

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

使用所指定演算法並使用目前的金鑰簽署雜湊,將簽章寫入提供的緩衝區,以嘗試雜湊處理所提供的資料。Attempts to hash the provided data with the specified algorithm and sign the hash with the current key, writing the signature into a provided buffer.

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

將簽章寫入提供的緩衝區,嘗試以目前的金鑰簽署雜湊。Attempts to sign the hash with the current key, writing the signature into a provided buffer.

(繼承來源 RSA)
VerifyData(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and padding, and comparing it to the provided signature.

(繼承來源 RSA)
VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的部分位元組陣列計算出資料的雜湊值,便藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and padding, and comparing it to the provided signature.

(繼承來源 RSA)
VerifyData(Byte[], Object, Byte[])

使用提供的公開金鑰,並和所提供資料的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the hash value of the provided data.

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

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and padding, and comparing it to the provided signature.

(繼承來源 RSA)
VerifyData(Stream, Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料流計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and padding, and comparing it to the provided signature.

(繼承來源 RSA)
VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the specified hashing algorithm and padding, and comparing it to the provided hash value.

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

使用指定的雜湊演算法和填補,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

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

使用提供的公開金鑰,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the provided hash value.

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

使用指定的雜湊演算法和填補,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

(繼承來源 RSA)

明確介面實作

IDisposable.Dispose()

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(繼承來源 AsymmetricAlgorithm)

適用於