HashAlgorithm
Contents
[
Hide
]PdfDigitalSignatureDetails.HashAlgorithm property
Gets or sets the hash algorithm.
public PdfDigitalSignatureHashAlgorithm HashAlgorithm { get; set; }
Remarks
The default value is the SHA-256 algorithm.
Examples
Shows how to sign a generated PDF document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Contents of signed PDF.");
CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
// Configure the "DigitalSignatureDetails" object of the "SaveOptions" object to
// digitally sign the document as we render it with the "Save" method.
DateTime signingTime = new DateTime(2015, 7, 20);
options.DigitalSignatureDetails =
new PdfDigitalSignatureDetails(certificateHolder, "Test Signing", "My Office", signingTime);
options.DigitalSignatureDetails.HashAlgorithm = PdfDigitalSignatureHashAlgorithm.RipeMD160;
Assert.AreEqual("Test Signing", options.DigitalSignatureDetails.Reason);
Assert.AreEqual("My Office", options.DigitalSignatureDetails.Location);
Assert.AreEqual(signingTime, options.DigitalSignatureDetails.SignatureDate.ToLocalTime());
Assert.AreEqual(certificateHolder, options.DigitalSignatureDetails.CertificateHolder);
doc.Save(ArtifactsDir + "PdfSaveOptions.PdfDigitalSignature.pdf", options);
See Also
- enum PdfDigitalSignatureHashAlgorithm
- class PdfDigitalSignatureDetails
- namespace Aspose.Words.Saving
- assembly Aspose.Words