翻譯|使用教程|編輯:李顯亮|2020-11-27 09:55:23.000|閱讀 325 次
概述:本文明確針對(duì)MS PowerPoint演示文稿的安全性,并提供保護(hù)PPTX文檔安全的不同方法。在本文中,將學(xué)習(xí)如何使用C#使用密碼或數(shù)字簽名保護(hù)PowerPoint PPTX。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數(shù)字信息的保護(hù)一直是網(wǎng)絡(luò)世界中的重要方面。為了保護(hù)數(shù)字內(nèi)容,已經(jīng)設(shè)計(jì)了各種方式和技術(shù)。因此,本文明確針對(duì)MS PowerPoint演示文稿的安全性,并提供保護(hù)PPTX文檔安全的不同方法。在本文中,將學(xué)習(xí)如何使用C#使用密碼或數(shù)字簽名保護(hù)PowerPoint PPTX。
>>你可以點(diǎn)擊這里下載Aspose.Slides v20.10測(cè)試體驗(yàn)。(安裝包僅提供部分功能,并設(shè)置限制,如需試用完整功能請(qǐng))
以下是使用密碼保護(hù)PowerPoint PPTX演示文稿的步驟。
下面的代碼示例演示如何使用C#使用密碼保護(hù)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); }
數(shù)字簽名是一種在證書的幫助下保護(hù)數(shù)字信息的流行方法。MS PowerPoint演示文稿還支持?jǐn)?shù)字簽名以保護(hù)內(nèi)容。以下是使用C#對(duì)PPTX文件進(jìn)行數(shù)字簽名的步驟。
下面的代碼示例演示如何使用C#在PowerPoint演示文稿中添加數(shù)字簽名。
// 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也允許您驗(yàn)證演示文稿是否經(jīng)過(guò)數(shù)字簽名。此外,您可以檢查文檔是否被篡改或修改。以下是執(zhí)行驗(yàn)證的步驟。
下面的代碼示例演示如何使用C#在PowerPoint演示文稿中驗(yàn)證數(shù)字簽名。
// 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."); } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn