英語で読む

次の方法で共有


RSAPKCS1SignatureFormatter クラス

定義

RSA PKCS #1 バージョン 1.5 の署名を作成します。

C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
C#
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
C#
[System.Runtime.InteropServices.ComVisible(true)]
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
継承
RSAPKCS1SignatureFormatter
属性

次の例では、PKCS #1 バージョン 1.5 署名を作成する方法を示します。

C#
using System;
using System.Security.Cryptography;

class RSASample
{

    static void Main()
    {
        try
        {
            //Create a new instance of RSA.
            using (RSA rsa = RSA.Create())
            {
                //The hash to sign.
                byte[] hash;
                using (SHA256 sha256 = SHA256.Create())
                {
                    byte[] data = new byte[] { 59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135 };
                    hash = sha256.ComputeHash(data);
                }

                //Create an RSASignatureFormatter object and pass it the 
                //RSA instance to transfer the key information.
                RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(rsa);

                //Set the hash algorithm to SHA256.
                RSAFormatter.SetHashAlgorithm("SHA256");

                //Create a signature for HashValue and return it.
                byte[] SignedHash = RSAFormatter.CreateSignature(hash);
            }
        }
        catch (CryptographicException e)
        {
            Console.WriteLine(e.Message);
        }
    }
}

注釈

このクラスは、 アルゴリズムを使用してデジタル署名を作成するために使用されます RSA

アルゴリズムを使用してデジタル署名を検証するには、 をRSA使用RSAPKCS1SignatureDeformatterします。

コンストラクター

RSAPKCS1SignatureFormatter()

RSAPKCS1SignatureFormatter クラスの新しいインスタンスを初期化します。

RSAPKCS1SignatureFormatter(AsymmetricAlgorithm)

指定したキーで、RSAPKCS1SignatureFormatter クラスの新しいインスタンスを初期化します。

メソッド

CreateSignature(Byte[])

指定されたデータの RSA PKCS #1 署名を作成します。

CreateSignature(HashAlgorithm)

指定されたハッシュ値から署名を作成します。

(継承元 AsymmetricSignatureFormatter)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
SetHashAlgorithm(String)

署名の作成に使用するハッシュ アルゴリズムを設定します。

SetKey(AsymmetricAlgorithm)

署名の作成に使用する秘密キーを設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

こちらもご覧ください