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 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.
    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 備註

建構函式

名稱 Description
RSACryptoServiceProvider()

初始化一個隨機金鑰對的新類別實例 RSACryptoServiceProvider

RSACryptoServiceProvider(CspParameters)

初始化一個新的類別實例 RSACryptoServiceProvider ,並以指定參數進行。

RSACryptoServiceProvider(Int32, CspParameters)

初始化一個以指定金鑰大小與參數的新類別實例 RSACryptoServiceProvider

RSACryptoServiceProvider(Int32)

初始化類別的新實例 RSACryptoServiceProvider ,使用指定鍵大小的隨機金鑰對。

欄位

名稱 Description
KeySizeValue

代表非對稱演算法所使用的金鑰模數的大小(以位元為單位)。

(繼承來源 AsymmetricAlgorithm)
LegalKeySizesValue

指定非對稱演算法所支援的金鑰大小。

(繼承來源 AsymmetricAlgorithm)

屬性

名稱 Description
CspKeyContainerInfo

取得 CspKeyContainerInfo 一個描述加密金鑰對額外資訊的物件。

KeyExchangeAlgorithm

取得此實作 RSA中可用的金鑰交換演算法名稱。

KeySize

會得到目前金鑰的大小。

LegalKeySizes

取得非對稱演算法所支援的金鑰大小。

LegalKeySizes

取得非對稱演算法所支援的金鑰大小。

(繼承來源 AsymmetricAlgorithm)
PersistKeyInCsp

取得或設定一個值,指示金鑰是否應持續保存在密碼服務提供者(CSP)中。

PublicOnly

會得到一個值,指示該物件是否 RSACryptoServiceProvider 僅包含公鑰。

SignatureAlgorithm

取得此實作 RSA中可用的簽名演算法名稱。

UseMachineKeyStore

取得或設定一個值,指示該金鑰是否應該持久存在於電腦的金鑰儲存庫,而非使用者設定檔儲存庫。

方法

名稱 Description
Clear()

釋放 AsymmetricAlgorithm 類別所使用的所有資源。

(繼承來源 AsymmetricAlgorithm)
Decrypt(Byte[], Boolean)
已淘汰.

RSA 演算法解密資料。

Decrypt(Byte[], RSAEncryptionPadding)

利用指定的填充解密先前已被 RSA 演算法加密的資料。

Decrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

透過指定的填充模式解密輸入資料。

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

透過指定的填充模式解密輸入資料。

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

此方法目前版本不支援。

Dispose()

釋放目前類別實例 AsymmetricAlgorithm 所使用的所有資源。

(繼承來源 AsymmetricAlgorithm)
Dispose(Boolean)

釋放類別使用的 AsymmetricAlgorithm 非管理資源,並可選擇性地釋放受管理資源。

(繼承來源 AsymmetricAlgorithm)
Encrypt(Byte[], Boolean)
已淘汰.

RSA 演算法加密資料。

Encrypt(Byte[], RSAEncryptionPadding)

利用 RSA 演算法加密資料,使用指定的填充。

Encrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

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

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

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

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

此方法目前版本不支援。

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<Byte>, PbeParameters)

匯出目前的金鑰,格式為 PKCS#8 EncryptedPrivateKeyInfo,並以位元組密碼(PEM 編碼)匯出。

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

以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰,並以字元密碼(PEM encoded)匯出。

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

在以字元密碼解密後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公私鑰對,替換該物件的金鑰。

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(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[], String)

計算指定雜湊值的簽名。

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

利用指定的填充計算指定雜湊值的簽章。

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

用目前的金鑰簽署雜湊值,並將簽章寫入提供的緩衝區。

(繼承來源 RSA)
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<Byte>, PbeParameters, Span<Char>, Int32)

嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰,並以位元組密碼(PEM 編碼)匯出。

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

以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰,並以字元密碼(PEM encoded)匯出。

(繼承來源 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[], String, Byte[])

透過利用提供的公鑰確定簽章中的雜湊值,並與所提供的雜湊值比較,驗證數位簽章的有效性。

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

透過使用指定的雜湊演算法與填充,確定簽章中的雜湊值,並與提供的雜湊值比較,驗證數位簽章的有效性。

(繼承來源 RSA)

明確介面實作

名稱 Description
IDisposable.Dispose()

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

關於此成員的描述,請參見 Dispose()

(繼承來源 AsymmetricAlgorithm)

適用於

另請參閱