// get a certificate with a private key var certificate = Certificate.LoadPfx("mycert.pfx", "password"); // load the content of a file we need to sign byte[] content = File.ReadAllBytes("document.pdf"); var contentInfo = new ContentInfo(content); // create a PKCS #7 SignedData object based on this, // the second argument specifies "detached" style var signedData = new SignedData(contentInfo, true); // add one ore more signers var signer = new SignerInfo(certificate); signedData.SignerInfos.Add(signer); // create the signature signedData.Sign(); // save the signature into a detached signature file using (var output = File.Create("document.pdf.p7s")) { signedData.Save(output); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)