翻譯|使用教程|編輯:李顯亮|2021-02-26 09:22:40.450|閱讀 209 次
概述:本文旨在以編程方式保護MS PowerPoint PPTX / PPT演示文稿。特別是,將學習如何使用Java中的密碼或數字簽名來保護PowerPoint文件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數字信息始終存在未經授權的用戶偽造,篡改或濫用的威脅。因此,采取了各種安全措施來保護信息。因此,本文旨在以編程方式保護MS PowerPoint PPTX / PPT演示文稿。特別是,將學習如何使用Java中的密碼或數字簽名來保護PowerPoint文件。
為了保護PowerPoint文件,將使用Aspose.Slides。它是一個功能強大且功能豐富的API,可用于創建,操作和轉換PowerPoint文件。此外,它使您可以使用密碼或數字簽名保護PowerPoint PPTX / PPT演示文稿。
>>你可以點擊這里下載Aspose.Slides for java最新版測試體驗。
以下是使用Aspose.Slides for Java用密碼保護PowerPoint PPTX文件的步驟。
下面的代碼示例演示如何使用Java保護PowerPoint PPTX文件。
// Instantiate a Presentation object that represents a presentation file
Presentation presentation = new Presentation("presentation.pptx");
// Protect PPTX with password
presentation.getProtectionManager().encrypt("password");
// Save the PPTX
presentation.save("protected-presentation.pptx", SaveFormat.Pptx);
還可以對PowerPoint PPTX演示文稿進行數字簽名,以確保其內容的真實性。以下是將數字簽名添加到PPTX文件的步驟。
下面的代碼示例演示如何使用Java對PowerPoint演示文稿進行數字簽名。
// Instantiate a Presentation object that represents a presentation file
Presentation presentation = 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.setComments("Aspose.Slides digital signing test.");
// Add digital signature to presentation
presentation.getDigitalSignatures().add(signature);
// Save the PPTX
presentation.save("protected-presentation.pptx", SaveFormat.Pptx);
除了添加數字簽名之外,您還可以驗證PowerPoint演示文稿中的現有簽名。以下是驗證PPTX文件中的數字簽名的步驟。
下面的代碼示例演示如何使用Java驗證PowerPoint PPTX文件中的數字簽名。
// Instantiate a Presentation object that represents a presentation file
Presentation presentation = new Presentation("presentation.pptx");
// Check if digital signatures are available
if (presentation.getDigitalSignatures().size() > 0) {
boolean allSignaturesAreValid = true;
// Loop through digital signatures
for (IDigitalSignature signature : presentation.getDigitalSignatures()) {
System.out.println(
signature.getSignTime().toString() + " -- " + (signature.isValid() ? "VALID" : "INVALID"));
allSignaturesAreValid &= signature.isValid();
}
if (allSignaturesAreValid)
System.out.println("Presentation is genuine, all signatures are valid.");
else
System.out.println("Presentation has been modified since signing.");
}
// Save the PPTX
presentation.save("protected-presentation.pptx", SaveFormat.Pptx);
如果你想試用Aspose的全部完整功能,可 聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn