A member of the PdfSignatureHash enumeration. The required hash algorithm to be used in the subsequent signing process.

Please check the returned status to find out if the specified hash is supported by your certificate.

Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / SetSignatureHash Method

SetSignatureHash Method (GdPicturePDF)

In This Topic
Specifies the hash algorithm to be used for the subsequent signing of the currently loaded PDF document. Now the SHA-256 algorithm is used as the standard, although with some old certificates you will still need to use SHA-1.

You can find more details about the SHA algorithms in RFC 6234 US Secure Hash Algorithms (SHA And SHA-based HMAC And HKDF).

Syntax
'Declaration
 
Public Function SetSignatureHash( _
   ByVal hashAlg As PdfSignatureHash _
) As GdPictureStatus
public GdPictureStatus SetSignatureHash( 
   PdfSignatureHash hashAlg
)
public function SetSignatureHash( 
    hashAlg: PdfSignatureHash
): GdPictureStatus; 
public function SetSignatureHash( 
   hashAlg : PdfSignatureHash
) : GdPictureStatus;
public: GdPictureStatus SetSignatureHash( 
   PdfSignatureHash hashAlg
) 
public:
GdPictureStatus SetSignatureHash( 
   PdfSignatureHash hashAlg
) 

Parameters

hashAlg
A member of the PdfSignatureHash enumeration. The required hash algorithm to be used in the subsequent signing process.

Please check the returned status to find out if the specified hash is supported by your certificate.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Be aware that you need to set up the required hash algorithm before you start the signing process. At the same, always check if your certificate supports the specified hash using the returned status.

Furthermore, from 2016 onward the SHA-1 algorithm is deprecated, the SHA-256 or stronger should be used instead if possible.

This method requires the Digital Signatures component to run.

Example
How to specify a required hash algorithm for the subsequent signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureHash"
Dim gdpicturePDF As New GdPicturePDF()
            
'Please load the PDF document you want to sign.
            
'Please set the corresponding certificate - this is a mandatory step.
            
'Set the hash algorithm.
'If this step is omitted, the value of PdfSignatureHash.SHA256 is used.
'If your certificate does not support this hash, the old PdfSignatureHash.SHA1 is used as default.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA512)
If status <> GdPictureStatus.OK Then
    MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption)
    Goto [Error]
End If
            
'Please see the complete sample in the ApplySignature() method for next steps to follow.
            
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureHash";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
            
//Please load the PDF document you want to sign.
            
//Please set the corresponding certificate - this is a mandatory step.
            
//Set the hash algorithm.
//If this step is omitted, the value of PdfSignatureHash.SHA256 is used.
//If your certificate does not support this hash, the old PdfSignatureHash.SHA1 is used as default.
GdPictureStatus status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA512);
if (status != GdPictureStatus.OK)
{
    MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption);
    goto error;
}
            
//Please see the complete sample in the ApplySignature() method for next steps to follow.
            
error:
gdpicturePDF.Dispose();
See Also