RSAPKCS1SignatureFormatter Klasse

Definition

Erstellt eine RSA PKCS #1 v1.5-Signatur.

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
Vererbung
RSAPKCS1SignatureFormatter
Attribute

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie eine PKCS #1 Version 1.5-Signatur erstellen.

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

Hinweise

Diese Klasse wird verwendet, um eine digitale Signatur mithilfe des RSA Algorithmus zu erstellen.

Verwenden Sie RSAPKCS1SignatureDeformatter zum Überprüfen digitaler Signaturen mit dem RSA Algorithmus.

Konstruktoren

RSAPKCS1SignatureFormatter()

Initialisiert eine neue Instanz der RSAPKCS1SignatureFormatter-Klasse.

RSAPKCS1SignatureFormatter(AsymmetricAlgorithm)

Initialisiert eine neue Instanz der RSAPKCS1SignatureFormatter-Klasse mit dem angegebenen Schlüssel.

Methoden

CreateSignature(Byte[])

Erstellt die RSA PKCS #1-Signatur für die angegebenen Daten.

CreateSignature(HashAlgorithm)

Erstellt die Signatur aus dem angegebenen Hashwert.

(Geerbt von AsymmetricSignatureFormatter)
Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
SetHashAlgorithm(String)

Legt den Hashalgorithmus fest, der zum Erstellen der Signatur verwendet werden soll.

SetKey(AsymmetricAlgorithm)

Legt den zum Erstellen der Signatur zu verwendenden privaten Schlüssel fest.

ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für

Siehe auch