DSASignatureFormatter Clase

Definición

Crea una firma del Algoritmo de firma digital (DSA).

public ref class DSASignatureFormatter : System::Security::Cryptography::AsymmetricSignatureFormatter
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class DSASignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
public class DSASignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public class DSASignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type DSASignatureFormatter = class
    inherit AsymmetricSignatureFormatter
type DSASignatureFormatter = class
    inherit AsymmetricSignatureFormatter
[<System.Runtime.InteropServices.ComVisible(true)>]
type DSASignatureFormatter = class
    inherit AsymmetricSignatureFormatter
Public Class DSASignatureFormatter
Inherits AsymmetricSignatureFormatter
Herencia
DSASignatureFormatter
Atributos

Ejemplos

#using <System.dll>

using namespace System;
using namespace System::Security::Cryptography;
int main()
{
   try
   {
      
      //Create a new instance of DSA.
      DSA^ DSA = DSA::Create();
      
      //The hash to sign.
      array<Byte>^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135};
      
      //Create an DSASignatureFormatter Object* and pass it the 
      //DSA instance to transfer the key information.
      DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA );
      
      //Set the hash algorithm to SHA1.
      DSAFormatter->SetHashAlgorithm( "SHA1" );
      
      //Create a signature for HashValue and return it.
      array<Byte>^SignedHash = DSAFormatter->CreateSignature( Hash );
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( e->Message );
   }

}
using System;
using System.Security.Cryptography;

class DSASample
{
        
    static void Main()
    {
        try
        {
            //Create a new instance of DSA.
            DSA DSA = DSA.Create();

            //The hash to sign.
            byte[] Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135};

            //Create an DSASignatureFormatter object and pass it the 
            //DSA instance to transfer the key information.
            DSASignatureFormatter DSAFormatter = new DSASignatureFormatter(DSA);

            //Set the hash algorithm to SHA1.
            DSAFormatter.SetHashAlgorithm("SHA1");

            //Create a signature for HashValue and return it.
            byte[] SignedHash = DSAFormatter.CreateSignature(Hash);
        }
        catch(CryptographicException e)
        {
            Console.WriteLine(e.Message);
        }
    }
}
Imports System.Security.Cryptography

 _

Class DSASample


    Shared Sub Main()
        Try
            'Create a new instance of DSA.
            Dim DSA As DSA = DSA.Create()

            'The hash to sign.
            Dim Hash As Byte() = {59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135}

            'Create an DSASignatureFormatter object and pass it the 
            'DSA instance to transfer the key information.
            Dim DSAFormatter As New DSASignatureFormatter(DSA)

            'Set the hash algorithm to SHA1.
            DSAFormatter.SetHashAlgorithm("SHA1")

            'Create a signature for HashValue and return it.
            Dim SignedHash As Byte() = DSAFormatter.CreateSignature(Hash)

        Catch e As CryptographicException
            Console.WriteLine(e.Message)
        End Try
    End Sub
End Class

Comentarios

Importante

Los creadores del algoritmo DSA han retirado su compatibilidad con él. Considere la posibilidad de usar la RSA clase o la ECDsa clase en lugar de la DSA clase . Use DSA solo para la compatibilidad con los datos y las aplicaciones heredadas.

Constructores

DSASignatureFormatter()

Inicializa una nueva instancia de la clase DSASignatureFormatter.

DSASignatureFormatter(AsymmetricAlgorithm)

Inicializa una nueva instancia de la clase DSASignatureFormatter con la clave especificada.

Métodos

CreateSignature(Byte[])

Crea la firma PKCS #1 del algoritmo de firma digital (DSA) para los datos especificados.

CreateSignature(HashAlgorithm)

Crea la signatura a partir del valor hash especificado.

(Heredado de AsymmetricSignatureFormatter)
Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
SetHashAlgorithm(String)

Especifica el algoritmo hash para el formateador de firmas del algoritmo de firma digital (DSA).

SetKey(AsymmetricAlgorithm)

Especifica la clave que se va a utilizar para el formateador de firmas del algoritmo de firma digital (DSA).

ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a

Consulte también