翻译|使用教程|编辑:李显亮|2020-11-27 09:55:23.000|阅读 27 次
概述:本文明确针对MS PowerPoint演示文稿的安全性,并提供保护PPTX文档安全的不同方法。在本文中,将学习如何使用C#使用密码或数字签名保护PowerPoint PPTX。
# 周年庆正版采购有优惠,点击咨询 # # 31款JAVA开发必备控件和工具 #
数字信息的保护一直是网络世界中的重要方面。为了保护数字内容,已经设计了各种方式和技术。因此,本文明确针对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."); } }
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果
好文不易,鼓励一下吧!