Free Support Forum - aspose.com

Fail to decrypt four encryption algorithm files

Fail to decrypt four encryption algorithm files. The encryption algorithm is the file name. The password is “test”.
bugs.zip (110.2 KB)

@dropin,

For Doc files, you can provide password to load encrypted documents via Aspose.Words API like this:
e.g
Sample code:

Aspose.Words.LoadOptions opts = new Aspose.Words.LoadOptions();
opts.LoadFormat = LoadFormat.Doc;
opts.Password = "myPassword";
Document doc = new Document("D:\\Temp\\in.doc", opts);
doc.Save("D:\\Temp\\18.8.doc"); 

Similarly you may provide encrypted password while loading the Excel files via Aspose.Cells APIs, you may also remove the password (if you want):
e.g
Sample code:

 LoadOptions loadoptions = new LoadOptions(LoadFormat.Excel97To2003);
            loadoptions.Password = "yourpassword";

            Workbook workbook = new Workbook("e:\\test2\\Book1.xls", loadoptions);
            workbook.Settings.Password = null; //Remove the password or decrypt it.
           workbook.Save("e:\\test2\\out1.xls");

You can reproduce the problems.

@dropin,

What is encrypted password for Excel file? Also, could you provide us your sample code (runnable) segments to reproduce the issue for DOC and Excel file formats, we will check it soon.

password is test

@dropin,

I tried giving “test” password in MS Excel but it gives error, could you check it? Also, could you provide us your sample code (runnable) segments to reproduce the issue for DOC and Excel file formats, we will check it soon,

public static int doFileConvert(String srcFilePath, String srcFileExtension, String password, String dstFilePath){
if(0 != checkFileExtension(srcFilePath)){
return -1;
}

    try{
        if (srcFileExtension.equalsIgnoreCase("doc")) {
            //System.out.println("file index: " + fileType +" - " + index + " - " + fileName);
            try {
				LoadOptions loadOptions = new LoadOptions();
				if(null != password) {
                    loadOptions.setPassword(password);
                }
                Document doc = new Document(srcFilePath, loadOptions);
                doc.removeMacros();
                doc.unprotect();
                doc.save(dstFilePath, SaveFormat.DOCX);
            }catch(com.aspose.words.IncorrectPasswordException e){
                return -2;
            }
            catch (Exception e) {
                //System.out.println(e);
                if(e.getCause().getMessage().contains("Unsupported encryption parameters") || password != null){//不支持这种文件解密
                    return -3;
                }
                return -1;
            }
        }
        else if(srcFileExtension.equalsIgnoreCase("xls")) {
            //System.out.println("file index: " + fileType +" - " + index + " - " + fileName);
            try {
                com.aspose.cells.LoadOptions loadOptions = new com.aspose.cells.LoadOptions();
                if(null != password) {
                    loadOptions.setPassword(password);
                }
                Workbook workbook = new Workbook(srcFilePath, loadOptions);
                workbook.getSettings().setPassword(null);
                workbook.save(dstFilePath, FileFormatType.XLSX);
            }
            catch (com.aspose.cells.CellsException e ){
                //System.out.println(e);
                System.out.println(e.getMessage());//com.aspose.cells.CellsException: Invalid password.
                if(e.getMessage().contains("password")){
                    // 密码错误或者文件是加密的
                    return -2;
                }
                return -1;
            }
            catch (Exception e) {
                //System.out.println(e);
                if( e instanceof java.lang.ArrayIndexOutOfBoundsException || password != null){ //出异常了。不支持这种文件解密
                    return -3;
                }
                return -1;
            }
        }
        else{
            return -1;
        }
    }
    catch (Exception e) {
        //e.printStackTrace();
    }
    return 0;
}

you can try open the four files with MS office, then click readonly button

@dropin,

Thanks for the code segments.

  1. Regarding DOC files
    We have found the issues and logged the following three tickets:
  • WORDSNET-17301: for RC4ú¼Microsoft Base Cryptographic Provider v1.0.doc
  • WORDSNET-17302: for RC4,Microsoft DH SChannel Cryptographic Provider.doc
  • WORDSNET-17303: for RC4,Microsoft Base DSS and Diffie-Hellman Cryptographic Provider.doc

Basically Aspose.Words throws the following error even when test password is applied:

Aspose.Words.FileCorruptedException
HResult=0x80131500
Message=The document appears to be corrupted and cannot b
Inner Exception 1:
InvalidOperationException: Unsupported encryption parameters.I have linked these issues to thread

  1. We could not evaluate your issue regarding MS Excel file format with Aspose.Cells APIs. When we tried giving “test” password in MS Excel to open the file “RC4,Microsoft Enhanced RSA and AES Cryptographic Provider.xls”, MS Excel gives error about wrong password, Please provide correct password to open the file.

截图1.png (41.0 KB)
截图21111.png (55.3 KB)
The correct password is test

@dropin,

Thanks for the screenshots.

I suspect the MS Excel file you are opening in your screenshot(s) (via “test” password) is not the same file in your attached zipped archive “bugs.zip”. I again tried to open the “RC4,Microsoft Enhanced RSA and AES Cryptographic Provider.xls” file and specify the password “test” but MS Excel again prompts me wrong password, see the attached demo video for your reference.
mv_file1.zip (1.4 MB)

The “RC4,Microsoft Enhanced RSA and AES Cryptographic Provider.xls” file is encrypted by WPS, and can only open by WPS. MS Excel cannot open it.

@dropin,

Well, Aspose.Cells follows MS Excel standards and specifications in general. If MS Excel cannot open/process it then Aspose.Cells also cannot do the same. You need to have an Excel file which should be encrypted in MS Excel, so, Aspose.Cells could process it fine.

The issues you have found earlier (filed as WORDSNET-17301,WORDSNET-17302,WORDSNET-17303) have been fixed in this Aspose.Words for .NET 18.9 update and this Aspose.Words for Java 18.9 update.