翻譯|使用教程|編輯:李顯亮|2021-02-26 09:22:40.450|閱讀 200 次
概述:本文旨在以編程方式保護MS PowerPoint PPTX / PPT演示文稿。特別是,將學(xué)習(xí)如何使用Java中的密碼或數(shù)字簽名來保護PowerPoint文件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數(shù)字信息始終存在未經(jīng)授權(quán)的用戶偽造,篡改或濫用的威脅。因此,采取了各種安全措施來保護信息。因此,本文旨在以編程方式保護MS PowerPoint PPTX / PPT演示文稿。特別是,將學(xué)習(xí)如何使用Java中的密碼或數(shù)字簽名來保護PowerPoint文件。
為了保護PowerPoint文件,將使用Aspose.Slides。它是一個功能強大且功能豐富的API,可用于創(chuàng)建,操作和轉(zhuǎn)換PowerPoint文件。此外,它使您可以使用密碼或數(shù)字簽名保護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演示文稿進行數(shù)字簽名,以確保其內(nèi)容的真實性。以下是將數(shù)字簽名添加到PPTX文件的步驟。
下面的代碼示例演示如何使用Java對PowerPoint演示文稿進行數(shù)字簽名。
// 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);
除了添加數(shù)字簽名之外,您還可以驗證PowerPoint演示文稿中的現(xiàn)有簽名。以下是驗證PPTX文件中的數(shù)字簽名的步驟。
下面的代碼示例演示如何使用Java驗證PowerPoint PPTX文件中的數(shù)字簽名。
// 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的全部完整功能,可 聯(lián)系在線客服獲取30天臨時授權(quán)體驗。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn