DSASignatureFormatter 类

定义

创建数字签名算法 (DSA) 签名。Creates a Digital Signature Algorithm (DSA) signature.

public ref class DSASignatureFormatter : System::Security::Cryptography::AsymmetricSignatureFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public class DSASignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter
type DSASignatureFormatter = class
    inherit AsymmetricSignatureFormatter
Public Class DSASignatureFormatter
Inherits AsymmetricSignatureFormatter
继承
DSASignatureFormatter
属性

示例

#using <System.dll>

using namespace System;
using namespace System::Security::Cryptography;
int main()
{
   try
   {
      
      //Create a new instance of DSACryptoServiceProvider.
      DSACryptoServiceProvider^ DSA = gcnew DSACryptoServiceProvider;
      
      //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 
      //DSACryptoServiceProvider 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 DSACryptoServiceProvider.
            DSACryptoServiceProvider DSA = new DSACryptoServiceProvider();

            //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 
            //DSACryptoServiceProvider 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 DSACryptoServiceProvider.
            Dim DSA As New DSACryptoServiceProvider()

            '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 
            'DSACryptoServiceProvider 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

构造函数

DSASignatureFormatter()

初始化 DSASignatureFormatter 类的新实例。Initializes a new instance of the DSASignatureFormatter class.

DSASignatureFormatter(AsymmetricAlgorithm)

使用指定的密钥初始化 DSASignatureFormatter 类的新实例。Initializes a new instance of the DSASignatureFormatter class with the specified key.

方法

CreateSignature(Byte[])

为指定的数据创建数字签名算法 (DSA) PKCS #1 签名。Creates the Digital Signature Algorithm (DSA) PKCS #1 signature for the specified data.

CreateSignature(HashAlgorithm)

通过指定的哈希值创建签名。Creates the signature from the specified hash value.

(继承自 AsymmetricSignatureFormatter)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
SetHashAlgorithm(String)

指定数字签名算法 (DSA) 签名格式化程序的哈希算法。Specifies the hash algorithm for the Digital Signature Algorithm (DSA) signature formatter.

SetKey(AsymmetricAlgorithm)

指定用于数字签名算法 (DSA) 签名格式化程序的密钥。Specifies the key to be used for the Digital Signature Algorithm (DSA) signature formatter.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅