翻譯|使用教程|編輯:李顯亮|2021-04-01 09:41:31.303|閱讀 206 次
概述:在演示文稿包含要保護的機密信息的情況下,用密碼保護演示文件可能會有所幫助。有鑒于此,本文將教您如何使用C ++通過密碼或數字簽名保護PowerPoint演示文稿。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Microsoft PowerPoint是功能強大且功能豐富的軟件,可讓您創建令人驚嘆的幻燈片以用于會議和討論。在演示文稿包含要保護的機密信息的情況下,用密碼保護演示文件可能會有所幫助。另一方面,如果想將演示文稿標記為最終演示并且不希望修改其內容,則可以對演示文稿文件進行數字簽名。只要簽名有效,就可以確信演示文件沒有被更改。有鑒于此,本文將教您如何使用C ++通過密碼或數字簽名保護PowerPoint演示文稿。
Aspose.Slides for C ++是功能豐富的C ++庫,可用于創建,讀取和修改PowerPoint文件。此外,API支持使用密碼和數字簽名保護PowerPoint文件。
>>你可以點擊這里下載Aspose.Slides 最新版測試體驗。
以下是使用密碼保護PowerPoint演示文稿的步驟。
以下是使用C ++用密碼保護PowerPoint演示文稿的示例代碼。
// File paths const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx"; const String outputFilePath = u"OutputDirectory\\protected-presentation.pptx"; // Load the presentation file SharedPtrpresentation = MakeObject(sourceFilePath); // Protect presentation with password presentation->get_ProtectionManager()->Encrypt(u"password"); // Save the presentation presentation->Save(outputFilePath, SaveFormat::Pptx);
以下是使用數字簽名保護PowerPoint演示文稿的步驟。
以下是使用C ++使用數字簽名保護PowerPoint文件的示例代碼。
// File paths const 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 file SharedPtrpresentation = MakeObject(sourceFilePath); // Create DigitalSignature object with PFX file and password SharedPtrsignature = MakeObject(signatureFilePath, u"testpass1"); // Add comment signature->set_Comments(u"Test Comments"); // Add digital signature to presentation presentation->get_DigitalSignatures()->Add(signature); // Save the presentation presentation->Save(outputFilePath, SaveFormat::Pptx);
Aspose.Slides for C ++ API還為您提供了驗證經過數字簽名的PowerPoint文件的功能。以下是驗證PowerPoint文件的數字簽名的步驟。
以下是用于使用C ++驗證PowerPoint文件的數字簽名的示例代碼。
// File path const String sourceFilePath = u"SourceDirectory\\digital-signature-presentation.pptx"; // Load the presentation file SharedPtrpresentation = MakeObject(sourceFilePath); // Check if presentation has digital signatures if (presentation->get_DigitalSignatures()->get_Count() > 0) { bool allSignaturesAreValid = true; Console::WriteLine(u"Signatures used to sign the presentation: "); // Verify digital signatures for (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天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn