- 使用密码保护PowerPoint文件
- 用数字签名保护PowerPoint文件
- 使用C ++验证经过数字签名的PowerPoint文件
Aspose.Slides for C ++是功能丰富的C ++库,可用于创建,读取和修改PowerPoint文件。此外,API支持使用密码和数字签名保护PowerPoint文件。
>>你可以点击这里下载Aspose.Slides 最新版测试体验。
整合所有格式API处理控件Aspose.Total永久授权火热促销中,联系客服立马1分钟了解全部!
使用密码保护PowerPoint文件
以下是使用密码保护PowerPoint演示文稿的步骤。
- 首先,使用Presentation 类加载PowerPoint文件 。
- 使用Presentation-> get_ProtectionManager()-> Encrypt(System :: String encryptionPassword)方法用密码对演示文稿进行加密。
- 最后,使用Presentation->Save (System::String name, Export::SaveFormat format)方法保存受保护的演示文稿。
以下是使用C ++用密码保护PowerPoint演示文稿的示例代码。
// File pathsconst String sourceFilePath = u"SourceDirectory\SamplePresentation.pptx";const String outputFilePath = u"OutputDirectory\protected-presentation.pptx";// Load the presentation fileSharedPtrpresentation = MakeObject(sourceFilePath);// Protect presentation with passwordpresentation->get_ProtectionManager()->Encrypt(u"password");// Save the presentationpresentation->Save(outputFilePath, SaveFormat::Pptx);
用数字签名保护PowerPoint文件
以下是使用数字签名保护PowerPoint演示文稿的步骤。
- 首先,使用Presentation 类加载PowerPoint演示 文稿。
- 使用证书文件和密码创建DigitalSignature类的对象。
- 使用DigitalSignature-> set_Comments(System :: String值)方法添加注释。
- 使用Presentation-> get_DigitalSignatures()-> Add(System :: SharedPtrdigitalSignature)方法将数字签名添加到演示文稿中。
- 最后,使用Presentation-> Save(系统::字符串名称,导出:: SaveFormat格式) 方法保存签名的演示 文稿。
以下是使用C ++使用数字签名保护PowerPoint文件的示例代码。
// File pathsconst String sourceFilePath = u"SourceDirectory\SamplePresentation.pptx";const String signatureFilePath = u"SourceDirectory\testsignature1.pfx";const String outputFilePath = u"OutputDirectory\digital-signature-presentation.pptx";// Load the presentation fileSharedPtrpresentation = MakeObject(sourceFilePath);// Create DigitalSignature object with PFX file and passwordSharedPtrsignature = MakeObject(signatureFilePath, u"testpass1");// Add commentsignature->set_Comments(u"Test Comments");// Add digital signature to presentationpresentation->get_DigitalSignatures()->Add(signature);// Save the presentationpresentation->Save(outputFilePath, SaveFormat::Pptx);
使用C ++验证经过数字签名的PowerPoint文件
Aspose.Slides for C ++ API还为您提供了验证经过数字签名的PowerPoint文件的功能。以下是验证PowerPoint文件的数字签名的步骤。
- 使用Presentation 类加载PowerPoint演示 文稿。
- 使用Presentation-> get_DigitalSignatures()-> get_Count()方法检查数字签名是否存在。
- 如果演示文稿包含数字签名,请遍历它们。
- 在循环中,使用Presentation-> get_DigitalSignatures()-> idx_get(int32_t索引)方法访问每个数字签名。
- 使用DigitalSignature-> get_IsValid()方法检查数字签名的有效性,该方法对有效签名返回true。
以下是用于使用C ++验证PowerPoint文件的数字签名的示例代码。
// File pathconst String sourceFilePath = u"SourceDirectory\digital-signature-presentation.pptx";// Load the presentation fileSharedPtrpresentation = MakeObject(sourceFilePath);// Check if presentation has digital signaturesif (presentation->get_DigitalSignatures()->get_Count() > 0){bool allSignaturesAreValid = true;Console::WriteLine(u"Signatures used to sign the presentation: ");// Verify digital signaturesfor (int i = 0; i < presentation->get_DigitalSignatures()->get_Count(); i++){SharedPtrsignature = presentation->get_DigitalSignatures()->idx_get(i);Console::WriteLine(System::Convert::ToString(signature->get_SignTime()) + u" -- " + (signature->get_IsValid() u"VALID" : u"INVALID"));if (signature->get_IsValid() == false){allSignaturesAreValid = false;}}if (allSignaturesAreValid){Console::WriteLine(u"Presentation is genuine, all signatures are valid.");}else{Console::WriteLine(u"Presentation has been modified since signing.");}}
如果你想试用Aspose的全部完整功能,可 联系在线客服获取30天临时授权体验。
还想要更多吗可以点击阅读【2020 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!