翻譯|使用教程|編輯:李顯亮|2020-11-27 09:55:23.000|閱讀 325 次
概述:本文明確針對MS PowerPoint演示文稿的安全性,并提供保護PPTX文檔安全的不同方法。在本文中,將學習如何使用C#使用密碼或數字簽名保護PowerPoint PPTX。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數字信息的保護一直是網絡世界中的重要方面。為了保護數字內容,已經設計了各種方式和技術。因此,本文明確針對MS PowerPoint演示文稿的安全性,并提供保護PPTX文檔安全的不同方法。在本文中,將學習如何使用C#使用密碼或數字簽名保護PowerPoint PPTX。
>>你可以點擊這里下載Aspose.Slides v20.10測試體驗。(安裝包僅提供部分功能,并設置限制,如需試用完整功能請)
以下是使用密碼保護PowerPoint PPTX演示文稿的步驟。
下面的代碼示例演示如何使用C#使用密碼保護PPTX。
// Instantiate a Presentation object that represents a presentation file using (Presentation pres = new Presentation("presentation.pptx")) { // Protect with password pres.ProtectionManager.Encrypt("password"); // Save presentation pres.Save("protected-presentation.pptx", Export.SaveFormat.Pptx); }
數字簽名是一種在證書的幫助下保護數字信息的流行方法。MS PowerPoint演示文稿還支持數字簽名以保護內容。以下是使用C#對PPTX文件進行數字簽名的步驟。
下面的代碼示例演示如何使用C#在PowerPoint演示文稿中添加數字簽名。
// Instantiate a Presentation object that represents a presentation file using (Presentation pres = new Presentation("presentation.pptx")) { // Create DigitalSignature object with PFX file and PFX password DigitalSignature signature = new DigitalSignature("testsignature1.pfx", @"testpass1"); // Comment new digital signature signature.Comments = "Aspose.Slides digital signing test."; // Add digital signature to presentation pres.DigitalSignatures.Add(signature); // Save presentation pres.Save("signed-presentation.pptx", Export.SaveFormat.Pptx); }
.NET的Aspose.Slides也允許您驗證演示文稿是否經過數字簽名。此外,您可以檢查文檔是否被篡改或修改。以下是執行驗證的步驟。
下面的代碼示例演示如何使用C#在PowerPoint演示文稿中驗證數字簽名。
// Instantiate a Presentation object that represents a presentation file using (Presentation pres = new Presentation("presentation.pptx")) { // Check if presentation has digital signatures if (pres.DigitalSignatures.Count > 0) { bool allSignaturesAreValid = true; Console.WriteLine("Signatures used to sign the presentation: "); // Check if all digital signatures are valid foreach (DigitalSignature signature in pres.DigitalSignatures) { Console.WriteLine(signature.Certificate.SubjectName.Name + ", " + signature.SignTime.ToString("yyyy-MM-dd HH:mm") + " -- " + (signature.IsValid ? "VALID" : "INVALID")); allSignaturesAreValid &= signature.IsValid; } if (allSignaturesAreValid) Console.WriteLine("Presentation is genuine, all signatures are valid."); else Console.WriteLine("Presentation has been modified since signing."); } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn