- Home
- Forum
- ASP.NET Core
- How to concatenate the signed hash to the original PDF?
How to concatenate the signed hash to the original PDF?
Hi,
I have .p7s file, How to concatenate the signed hash to the original PDF?
Please help
Thanks
SIGN IN To post a reply.
5 Replies
PH
Praveenkumar H
Syncfusion Team
March 6, 2020 11:16 AM UTC
Hi PTDigtial
We cannot directly embed the .p7s file in PDF document, since digital signature involves the following step.
1. Get the hash from the PDF document.
2. Sign the hash of the PDF document in local or from signature service.
3. Finally embed singed signature into the PDF document.
So can you please provide more details (code snippet or samples) about how you generated .p7s file so that we can provide exact solution to your requirement.
Regards,
Praveen
WI
Winanjaya
March 7, 2020 03:34 AM UTC
so the hash of PDF will be sent to EJBCA?.. how to get PDF's hash value?
PH
Praveenkumar H
Syncfusion Team
March 9, 2020 12:24 PM UTC
Hi Winanjaya
Yes the hash of the PDF document need to be send to signature service, you can get the hash of the PDF document using below code snippet.
|
FileStream documentStream = new FileStream("PDF_Succinctly.pdf ", FileMode.Open, FileAccess.Read);
//Load the existing PDF document
PdfLoadedDocument document = new PdfLoadedDocument(documentStream);
//Creates a digital signature
PdfSignature signature = new PdfSignature(document, document.Pages[0], null, "DigitalSignature");
signature.ComputeHash += Signature_ComputeHash;
MemoryStream ms = new MemoryStream();
document.Save(ms);
document.Close(true);
private static void Signature_ComputeHash1(object sender, PdfSignatureEventArgs ars)
{
//Get the document bytes and calculate the hash of the bytes.
byte[] hash = System.Security.Cryptography.SHA512.Create().ComputeHash(ars.Data);
} |
Regards,
Praveen
WI
Winanjaya
March 13, 2020 08:45 AM UTC
How about if the pdf password protected?
MK
Moorthy Karunanithi
Syncfusion Team
March 16, 2020 12:58 PM UTC
Hi Winanjaya,
|
How about if the pdf password protected? |
Yes, we can use the same code for the password-protected PDF documents too. |
Regards,
Moorthy K
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
WI Winanjaya
- Mar 5, 2020 10:06 AM UTC
- Mar 16, 2020 12:58 PM UTC