<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
/* Page Definitions */
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:237985010;
        mso-list-type:hybrid;
        mso-list-template-ids:456937178 460484200 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:18.0pt;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%2\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:42.0pt;
        text-indent:-21.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:63.0pt;
        text-indent:-21.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:84.0pt;
        text-indent:-21.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%5\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:105.0pt;
        text-indent:-21.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:126.0pt;
        text-indent:-21.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:147.0pt;
        text-indent:-21.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%8\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:168.0pt;
        text-indent:-21.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:189.0pt;
        text-indent:-21.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="blue" vlink="purple" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoPlainText"><span lang="EN-US">Hi Michael,<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Thanks a lot for your hint!<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">But I still got some problems. With your suggestion, I used these two jars which looks like the new version.
<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:15.75pt;mso-para-margin-left:1.5gd"><i><span lang="EN-US">-odfdom-java-0.8.10-incubation-SNAPSHOT-jar-with-dependencies.jar<o:p></o:p></span></i></p>
<p class="MsoPlainText" style="margin-left:15.75pt;mso-para-margin-left:1.5gd"><i><span lang="EN-US">-simple-odf-0.8.1-incubation-SNAPSHOT-jar-with-dependencies.jar<o:p></o:p></span></i></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">ENV: Libreoffice 4.1.4.2 & Libreoffice 3.x / java 1.7<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText" style="margin-left:18.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span lang="EN-US"><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><![endif]><span lang="EN-US">Open a .ods file manually, save it with password.
<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:18.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><i><span lang="EN-US"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">      
</span></span></span></i><![endif]><span lang="EN-US">In code, execute </span><b><span lang="EN-US" style="font-family:"Courier New"">“</span><span lang="EN-US">SpreadsheetDocument.loadDocument(File file, String password)</span></b><b><span lang="EN-US" style="font-family:"Courier New"">”</span></b><span lang="EN-US">,
 it always throw NullPointer Exception.<i><o:p></o:p></i></span></p>
<p class="MsoPlainText" style="margin-left:18.0pt"><span lang="EN-US">->After checking the source code, the code in ZipHelper.line87:
<b>System.getProperty(</b></span><b><span lang="EN-US" style="font-family:"Courier New"">“</span><span lang="EN-US">Java.version</span></b><b><span lang="EN-US" style="font-family:"Courier New"">”</span><span lang="EN-US">).equals(</span></b><b><span lang="EN-US" style="font-family:"Courier New"">…</span><span lang="EN-US">)
</span></b><span lang="EN-US">in try/catch will throw NullPointer.<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:18.0pt"><span lang="EN-US">->Obviously the parameter here should use
</span><span lang="EN-US" style="font-family:"Courier New"">“</span><span lang="EN-US">java.version</span><span lang="EN-US" style="font-family:"Courier New"">”</span><span lang="EN-US"> instead, but the code in line83: inputStream.getNextEntry() always throw
 java.util.zip.ZipException: only DEFLATED entries can have EXT descriptor, which is the key reason.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Then I tried API to load a unencrypted .ods file and save it with password with code
<b>org.odftoolkit.simple.Document.save(File file, String pasword)</b>. In this case, I can load the encrypted file with code.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Based on this situation, I don</span><span lang="EN-US" style="font-family:"Courier New"">’</span><span lang="EN-US">t know if you tried with this API before. And do you have some more information?<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Thanks again!     <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Best Regards<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">William<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">-----Original Message-----<br>
From: Michael Stahl [mailto:mstahl@redhat.com] <br>
Sent: 2016</span><span style="font-family:宋体">年</span><span lang="EN-US">1</span><span style="font-family:宋体">月</span><span lang="EN-US">5</span><span style="font-family:宋体">日</span><span lang="EN-US"> 0:39<br>
To: Zhang, William; libreoffice@lists.freedesktop.org<br>
Subject: Re: How to decrypt ods file</span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">On 25.12.2015 06:08, Zhang, William wrote:<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> Does anyone know how to decrypt an encrypted Libreoffice Calc file
<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> with Java or other languages? Or even some workarounds. Thanks a lot!<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">the Apache ODF Toolkit ODFDOM library supports ODF encryption, at least with the "old" Blowfish/SHA1 algorithms that were used in LO <= 3.5 (i'm not aware if anybody has added support for AES, which is used since LO
 3.5).<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><a href="http://incubator.apache.org/odftoolkit/odfdom/index.html"><span style="color:windowtext;text-decoration:none">http://incubator.apache.org/odftoolkit/odfdom/index.html</span></a><o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">see the "password" parameter on the constructor of class org.odftoolkit.odfdom.pkg.OdfPackage<o:p></o:p></span></p>
</div>
</body>
</html>