使用JAVA調用KRPANO加密XML

來源:互聯網
上載者:User

標籤:input   use   red   setting   get   說明   命令列   port   exception   

KRPano內建的命令列工具krpanotools可以加密XML,具體的參數說明如下
文法:

 
krpanotools32.exe encrypt [OPTIONS] inputfiles

 


inputfiles 參數可以是任意個數的檔案 (支援*)

選項:
-h5 … 使用HTML5相容的加密方式
-bin … 使用僅支援Flash的加密方式
-p … 使用公用祕密金鑰加密
-z … 加密並壓縮檔
-ow … 覆蓋源檔案
-bk … 覆蓋源檔案並備份源檔案
-in=# … 手動設定待加密檔案路徑
-out=# … 手動設定輸出檔案路徑
-q … 不顯示輸出資訊

 

例如,下面的例子會把目錄下的tour.xml加密,加密後儲存為tour_enc.xml

 
 krpanotools32 encrypt -in="tour.xml" -out="tour_enc.xml"

 

我們可以在Java代碼中調用該命令列,實現通過程式去加密XML檔案

import java.io.IOException;import java.lang.ProcessBuilder;import java.io.*; public class KrXmlEncryption {    public static void main(String[] args) throws IOException {        encryptXML("tour.xml", "tour_enc.xml");    }     public static void encryptXML(String srcPath, String outPath) throws IOException {        Process process = new ProcessBuilder("krpanotools32.exe", "encrypt", "-z", String.format("-in=\"%s\"", srcPath),                String.format("-out=\"%s\"", outPath)).start();        BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));        String line;        while ((line = input.readLine()) != null) {            System.out.println(line);        }    }}

  

  

encryptXML函數有兩個參數

srcPath:XML源檔案的路徑

outPath:XML加密後檔案儲存的路徑

調用該函數可以把srcPath的XML加密後儲存到outPath

 

如果你需要更強力的加密方式,可以參考這篇文章

http://www.krpano.tech/archives/187

 

本博文發表於:http://www.krpano.tech/archives/546

發行者:屠龍

轉載請註明出處,謝謝!

使用JAVA調用KRPANO加密XML

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.