Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jan 04, 2022 7:54 am

[b]I Want To ask Question About How can change Encryption algorithm Used in signing documernt from sha-1 to sha-2 /sha256 i wnt to ask if there are any way to change Encryption algorithm from sha-1 to sha-2.

Mohamed_Abdelhamed
 
Posts: 1
Joined: Tue Jan 04, 2022 7:38 am

Tue Jan 04, 2022 8:13 am

Dear Mohamed,

Thanks for your inquiry.
The Hash Algorithm used in our Spire.PDF is SHA1 by default, sorry currently it is not available to change as SHA-2 or SHA-256. We will consider adding it as a new feature into our future upgrade, if it is achieved, I will inform you immediately.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Tue Jan 04, 2022 10:03 pm

we also need this feature ... can you please provide us with estimated delivery date ?

mina5500
 
Posts: 4
Joined: Mon Oct 11, 2021 5:23 pm

Wed Jan 05, 2022 5:46 am

Dear Mina,

Our dev team will carry out investigations on this feature and new features generally take longer to develop. As of now, I am unable to provide an estimated date, however if there is any progress or any plans to achieve the goal have been made, I will inform you.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Wed Jan 05, 2022 9:31 am

Thanks but can you please check if there is a workaround like the one below from syncfusion ... in order to inject the algorithm on the current version of library?

https://www.syncfusion.com/forums/15489 ... -only-sha1
(last reply at end of page)

as we need this feature as soon as possible

mina5500
 
Posts: 4
Joined: Mon Oct 11, 2021 5:23 pm

Wed Jan 05, 2022 10:06 am

Hi,

Thanks for your sharing.
I will post the link you provided to our Dev team for reference and urge them to make plans as soon as possible. I will keep you informed regarding any progress.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Wed May 13, 2026 3:47 am

Hi,

Thanks for your patient waiting.
I'm glad to inform you that we just released the Spire.PDF Pack(Hotfix) Version:12.5.1, which supports using SHA-2 and SHA-256 algorithms for signing, please download the new version from the following link and refer to the code below to test.

Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/12.5.1
https://www.nuget.org/packages/Spire.PDFfor.NETStandard/12.5.1

Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);

X509Certificate2 cert = new X509Certificate2(inputFile_pfx, "e-iceblue");
IPdfSignatureFormatter formatter = new PdfPKCS7Formatter(cert, false);
PdfMDPSignatureMaker pdfMDPSignatureMaker = new PdfMDPSignatureMaker(pdf, formatter);
PdfSignature signature = pdfMDPSignatureMaker.Signature;
signature.Name = "e-iceblue";
signature.ContactInfo = "028-81705109";
signature.Location = "chengdu";
signature.Reason = " this document";

PdfSignatureAppearance appearance = new PdfSignatureAppearance(signature);
appearance.NameLabel = "Signer: ";
appearance.ContactInfoLabel = "ContactInfo: ";
appearance.LocationLabel = "Loaction: ";
appearance.ReasonLabel = "Reason: ";
pdfMDPSignatureMaker.MakeSignature("signName", pdf.Pages[0], 100, 100, 250, 200, appearance);
foreach (HashAlgorithmType hashAlgorithmType in Enum.GetValues(typeof(HashAlgorithmType)))
{
    if (string.Equals(hashAlgorithmType.ToString(), "SM3", StringComparison.OrdinalIgnoreCase))
    {
        continue;
    }
    formatter.Properties.HashAlgorithm = hashAlgorithmType;
    try
    {
        pdf.SaveToFile(outputFile + hashAlgorithmType + ".pdf", FileFormat.PDF);
        Console.WriteLine($"成功:{hashAlgorithmType}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Failed,HashAlgorithmType:{hashAlgorithmType}");
        Console.WriteLine($"Error Info:{ex.Message}");
    }
}
pdf.Dispose();

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron