RSAPKCS1SignatureFormatter クラス
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
RSA PKCS #1 バージョン 1.5 の署名を作成します。
public ref class RSAPKCS1SignatureFormatter : System::Security::Cryptography::AsymmetricSignatureFormatter
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type RSAPKCS1SignatureFormatter = class
inherit AsymmetricSignatureFormatter
type RSAPKCS1SignatureFormatter = class
inherit AsymmetricSignatureFormatter
[<System.Runtime.InteropServices.ComVisible(true)>]
type RSAPKCS1SignatureFormatter = class
inherit AsymmetricSignatureFormatter
Public Class RSAPKCS1SignatureFormatter
Inherits AsymmetricSignatureFormatter
- 継承
- 属性
次の例では、PKCS #1 バージョン 1.5 署名を作成する方法を示します。
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);
}
}
}
Imports System.Security.Cryptography
Friend Class RSASample
Shared Sub Main()
Try
'Create a new instance of RSA.
Using rsa As RSA = RSA.Create()
'The hash to sign.
Dim hash() As Byte
Using sha256 As SHA256 = SHA256.Create()
Dim data() As 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)
End Using
'Create an RSASignatureFormatter object and pass it the
'RSA to transfer the key information.
Dim RSAFormatter As New RSAPKCS1SignatureFormatter(rsa)
'Set the hash algorithm to SHA256.
RSAFormatter.SetHashAlgorithm("SHA256")
'Create a signature for HashValue and return it.
Dim SignedHash() As Byte = RSAFormatter.CreateSignature(hash)
End Using
Catch e As CryptographicException
Console.WriteLine(e.Message)
End Try
End Sub
End Class
このクラスは、 アルゴリズムを使用してデジタル署名を作成するために使用されます RSA 。
アルゴリズムを使用してデジタル署名を検証するには、 をRSA使用RSAPKCS1SignatureDeformatterします。
RSAPKCS1Signature |
RSAPKCS1SignatureFormatter クラスの新しいインスタンスを初期化します。 |
RSAPKCS1Signature |
指定したキーで、RSAPKCS1SignatureFormatter クラスの新しいインスタンスを初期化します。 |
Create |
指定されたデータの RSA PKCS #1 署名を作成します。 |
Create |
指定されたハッシュ値から署名を作成します。 (継承元 AsymmetricSignatureFormatter) |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
Get |
既定のハッシュ関数として機能します。 (継承元 Object) |
Get |
現在のインスタンスの Type を取得します。 (継承元 Object) |
Memberwise |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
Set |
署名の作成に使用するハッシュ アルゴリズムを設定します。 |
Set |
署名の作成に使用する秘密キーを設定します。 |
To |
現在のオブジェクトを表す文字列を返します。 (継承元 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 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。