DSASignatureFormatter Classe
Definição
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
- Herança
- Atributos
Exemplos
#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
Comentários
Importante
Os criadores do algoritmo DSA retiraram seu suporte para ele.The creators of the DSA algorithm have withdrawn their support for it. Considere usar a classe RSA ou a ECDsa classe em vez da DSA classe.Consider using the RSA class or the ECDsa class instead of the DSA class. Use DSA apenas para compatibilidade com dados e aplicativos herdados.Use DSA only for compatibility with legacy applications and data.
Construtores
| DSASignatureFormatter() |
Inicializa uma nova instância da classe DSASignatureFormatter.Initializes a new instance of the DSASignatureFormatter class. |
| DSASignatureFormatter(AsymmetricAlgorithm) |
Inicializa uma nova instância da classe DSASignatureFormatter com a chave especificada.Initializes a new instance of the DSASignatureFormatter class with the specified key. |
Métodos
| CreateSignature(Byte[]) |
Cria a assinatura PKCS nº 1 DSA (Algoritmo de Assinatura Digital) para os dados especificados.Creates the Digital Signature Algorithm (DSA) PKCS #1 signature for the specified data. |
| CreateSignature(HashAlgorithm) |
Cria a assinatura com o valor de hash especificado.Creates the signature from the specified hash value. (Herdado de AsymmetricSignatureFormatter) |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| SetHashAlgorithm(String) |
Especifica o algoritmo de hash para o formatador de assinatura DSA (Algoritmo de Assinatura Digital).Specifies the hash algorithm for the Digital Signature Algorithm (DSA) signature formatter. |
| SetKey(AsymmetricAlgorithm) |
Especifica a chave a ser usada para o formatador de assinatura DSA (Algoritmo de Assinatura Digital).Specifies the key to be used for the Digital Signature Algorithm (DSA) signature formatter. |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |