標籤: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