Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apache POI解密文档文件无法处理加密文件? public static void decryptedDoc(字符串路径,字符串[]密码)抛出FileNotFoundException,IOException{ FileOutputStream fileOut=null; 对于(int i=0;i_Java_Encryption_Apache Poi_Doc - Fatal编程技术网

Java Apache POI解密文档文件无法处理加密文件? public static void decryptedDoc(字符串路径,字符串[]密码)抛出FileNotFoundException,IOException{ FileOutputStream fileOut=null; 对于(int i=0;i

Java Apache POI解密文档文件无法处理加密文件? public static void decryptedDoc(字符串路径,字符串[]密码)抛出FileNotFoundException,IOException{ FileOutputStream fileOut=null; 对于(int i=0;i,java,encryption,apache-poi,doc,Java,Encryption,Apache Poi,Doc,,如您在问题中链接到的中的图表所示: HWPF是处理Word.doc文件的Apache POI组件,它不支持对受密码保护的.doc文件进行解密。因此,如果您尝试(如您所做的那样),将出现异常 如表所示,所有基于OOXML的格式都以加密/密码保护的形式得到支持,因为它们都使用一种通用的方式存储受保护的内容。较旧的文件格式都有自己的处理方式,这要求每种格式都有独立的实现。支持最常见的一种用途d用于HSSF中的xls,用于HSLF中的ppt中使用的一种,但HWPF中不支持doc 如果这对您来说真的很重

,如您在问题中链接到的中的图表所示:

HWPF是处理Word
.doc
文件的Apache POI组件,它不支持对受密码保护的
.doc
文件进行解密。因此,如果您尝试(如您所做的那样),将出现异常

如表所示,所有基于OOXML的格式都以加密/密码保护的形式得到支持,因为它们都使用一种通用的方式存储受保护的内容。较旧的文件格式都有自己的处理方式,这要求每种格式都有独立的实现。支持最常见的一种用途d用于HSSF中的
xls
,用于HSLF中的
ppt
中使用的一种,但HWPF中不支持
doc


如果这对您来说真的很重要,您需要阅读Microsoft发布的文件格式文档,了解.doc文件是如何进行加密的,然后添加支持并将其贡献回来。thx中提供了很多相关链接。我将尝试找出是否有其他库支持此功能。我已经实现了反加密In同时-检查处理单据/单据
public static void decryptedDoc(String path,String[] password) throws FileNotFoundException, IOException{
  FileOutputStream fileOut = null;
  for(int i=0;i<password.length;i++){
//  try{
  Biff8EncryptionKey.setCurrentUserPassword(password[i]);
  NPOIFSFileSystem fs = new NPOIFSFileSystem( new FileInputStream(path));
  HWPFDocument doc=new HWPFDocument(fs.getRoot());
  Biff8EncryptionKey.setCurrentUserPassword(null);
  String neweachpath=path.substring(0, path.length()-4)+"_decrypted"+path.substring(path.length() -4);
  fileOut = new FileOutputStream(neweachpath);
  doc.write(fileOut);
  fileOut.flush(); 
  //}
 /* catch (EncryptedDocumentException e){
      System.out.println("wrong password for"+path+password[i]);
  }*/
  }