RSACryptoServiceProvider.Decrypt メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RSACryptoServiceProvider.Decrypt メソッドの意味・解説 

RSACryptoServiceProvider.Decrypt メソッド

RSA アルゴリズムデータ復号化ます。

名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

CryptographicException

暗号サービス プロバイダ (CSP) を取得できません。

または

fOAEP パラメータtrue であり、rgb パラメータ長さKeySize超える値です。

または

fOAEP パラメータtrue で、OAEPサポートされていません。

解説解説

このメソッド使用して復号化できるデータ暗号化するには、Encrypt を使用します

使用例使用例

データ暗号化と復号化を行うコード例次に示します

Imports System.Security.Cryptography
Imports System.Text

Module RSACSPExample

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

            Dim dataString As String
 = "Data to Encrypt"

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

            'Create a new instance of the RSACryptoServiceProvider class
 
            ' and automatically create a new key-pair.
            Dim RSAalg As New
 RSACryptoServiceProvider

            'Display the origianl data to the console.
            Console.WriteLine("Original Data: {0}",
 dataString)

            'Encrypt the byte array and specify no OAEP padding.  
            'OAEP padding is only available on Microsoft Windows XP
 or
            'later.  
            encryptedData = RSAalg.Encrypt(dataToEncrypt, False)

            'Display the encrypted data to the console. 
            Console.WriteLine("Encrypted Data: {0}",
 ByteConverter.GetString(encryptedData))

            'Pass the data to ENCRYPT and boolean flag specifying 
            'no OAEP padding.
            decryptedData = RSAalg.Decrypt(encryptedData, False)

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

End Module
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.
            ASCIIEncoding ByteConverter = new ASCIIEncoding();

            string dataString = "Data to Encrypt";

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

            //Create a new instance of the RSACryptoServiceProvider
 class 
            // and automatically create a new key-pair.
            RSACryptoServiceProvider RSAalg = new RSACryptoServiceProvider();

            //Display the origianl data to the console.
            Console.WriteLine("Original Data: {0}", dataString);

            //Encrypt the byte array and specify no OAEP padding.  
            //OAEP padding is only available on Microsoft Windows XP
 or
            //later.  
            encryptedData = RSAalg.Encrypt(dataToEncrypt, false);

            //Display the encrypted data to the console. 
            Console.WriteLine("Encrypted Data: {0}", ByteConverter.GetString(encryptedData));

            //Pass the data to ENCRYPT and boolean flag specifying 
            //no OAEP padding.
            decryptedData = RSAalg.Decrypt(encryptedData, false);

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

        }
    }
}
using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
int main()
{
   try
   {
      
      //Create a UnicodeEncoder to convert between byte array and string.
      ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding;
      String^ dataString = "Data to Encrypt";
      
      //Create byte arrays to hold original, encrypted, and decrypted
 data.
      array<Byte>^dataToEncrypt = ByteConverter->GetBytes( dataString );
      array<Byte>^encryptedData;
      array<Byte>^decryptedData;
      
      //Create a new instance of the RSACryptoServiceProvider class
 
      // and automatically create a new key-pair.
      RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
      
      //Display the origianl data to the console.
      Console::WriteLine( "Original Data: {0}", dataString );
      
      //Encrypt the byte array and specify no OAEP padding.  
      //OAEP padding is only available on Microsoft Windows XP or
      //later.  
      encryptedData = RSAalg->Encrypt( dataToEncrypt, false
 );
      
      //Display the encrypted data to the console. 
      Console::WriteLine( "Encrypted Data: {0}", ByteConverter->GetString(
 encryptedData ) );
      
      //Pass the data to ENCRYPT and boolean flag specifying 
      //no OAEP padding.
      decryptedData = RSAalg->Decrypt( encryptedData, false
 );
      
      //Display the decrypted plaintext to the console. 
      Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString(
 decryptedData ) );
   }
   catch ( CryptographicException^ e ) 
   {
      
      //Catch this exception in case the encryption did
      //not succeed.
      Console::WriteLine( e->Message );
   }

}

import System.*;
import System.Security.Cryptography.*;
import System.Text.*;

class RSACSPSample
{
    public static void main(String[]
 args)
    {
        try {
            // Create a UnicodeEncoder to convert between byte array
 and string.
            ASCIIEncoding byteConverter = new ASCIIEncoding();
            String dataString = "Data to Encrypt";

            // Create byte arrays to hold original, encrypted, and decrypted
 
            // data.
            ubyte dataToEncrypt[] = byteConverter.GetBytes(dataString);
            ubyte encryptedData[];
            ubyte decryptedData[];

            // Create a new instance of the RSACryptoServiceProvider
 class 
            // and automatically create a new key-pair.
            RSACryptoServiceProvider rsaAlg = new RSACryptoServiceProvider();

            //Display the origianl data to the console.
            Console.WriteLine("Original Data: {0}", dataString);

            // Encrypt the byte array and specify no OAEP padding. 
 
            // OAEP padding is only available on Microsoft Windows XP
 or
            // later.  
            encryptedData = rsaAlg.Encrypt(dataToEncrypt, false);

            // Display the encrypted data to the console. 
            Console.WriteLine("Encrypted Data: {0}", 
                byteConverter.GetString(encryptedData));

            // Pass the data to ENCRYPT and boolean flag specifying
 
            // no OAEP padding.
            decryptedData = rsaAlg.Decrypt(encryptedData, false);

            // Display the decrypted plaintext to the console. 
            Console.WriteLine("Decrypted plaintext: {0}", 
                byteConverter.GetString(decryptedData));
        }
        catch (CryptographicException e) {
            // Catch this exception in case the encryption did
            // not succeed.
            Console.WriteLine(e.get_Message());
        }
    } //main
} //RSACSPSample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
RSACryptoServiceProvider クラス
RSACryptoServiceProvider メンバ
System.Security.Cryptography 名前空間
その他の技術情報
暗号サービス


このページでは「.NET Framework クラス ライブラリ リファレンス」からRSACryptoServiceProvider.Decrypt メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRSACryptoServiceProvider.Decrypt メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRSACryptoServiceProvider.Decrypt メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RSACryptoServiceProvider.Decrypt メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RSACryptoServiceProvider.Decrypt メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS