語言

DSASignatureFormatter 類別

定義

建立數位簽章演算法(DSA)簽名。

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

範例

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

備註

Important

DSA 演算法的創建者已撤回對其的支持。 考慮用 class 或 RSA class 代替 ECDsa class DSA 。 僅用於 DSA 與舊有應用程式及資料相容性。

建構函式

名稱 Description
DSASignatureFormatter()

初始化 DSASignatureFormatter 類別的新執行個體。

DSASignatureFormatter(AsymmetricAlgorithm)

初始化一個新的類別實例 DSASignatureFormatter ,使用指定的鍵值。

方法

名稱 Description
CreateSignature(Byte[])

為指定資料建立數位簽章演算法(DSAPKCS #1)簽章。

CreateSignature(HashAlgorithm)

從指定的雜湊值建立簽章。

(繼承來源 AsymmetricSignatureFormatter)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type。

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
SetHashAlgorithm(String)

規定數位簽章演算法(DSA)簽名格式器的雜湊演算法。

SetKey(AsymmetricAlgorithm)

指定用於數位簽章演算法(DSA)簽名格式化器的金鑰。

ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於

另請參閱