encryptedData = cipher.doFinal(compressedData, 0, compressedDataLength);
// 9.update file entry encryption data.
String checksum = new Base64Binary(checksumBytes).toString();
FileEntryElement fileEntryElement = fileEntry.getOdfElement();
EncryptionDataElement encryptionDataElement = OdfElement.findFirstChildNode(EncryptionDataElement.class, fileEntryElement);
if (encryptionDataElement != null) {
fileEntryElement.removeChild(encryptionDataElement);
}
encryptionDataElement = fileEntryElement.newEncryptionDataElement(checksum, "SHA1/1K");
String initialisationVector = new Base64Binary(iv).toString();
AlgorithmElement algorithmElement = OdfElement.findFirstChildNode(AlgorithmElement.class, encryptionDataElement);
if (algorithmElement != null) {
encryptionDataElement.removeChild(algorithmElement);
}
algorithmElement = encryptionDataElement.newAlgorithmElement("Blowfish CFB", initialisationVector);
String saltStr = new Base64Binary(salt).toString();
KeyDerivationElement keyDerivationElement = OdfElement.findFirstChildNode(KeyDerivationElement.class, encryptionDataElement);
if (keyDerivationElement != null) {
encryptionDataElement.removeChild(keyDerivationElement);
}
keyDerivationElement = encryptionDataElement.newKeyDerivationElement(1024, "PBKDF2", saltStr);
StartKeyGenerationElement startKeyGenerationElement = OdfElement.findFirstChildNode(StartKeyGenerationElement.class, encryptionDataElement);
if (startKeyGenerationElement != null) {
encryptionDataElement.removeChild(startKeyGenerationElement);
}
encryptionDataElement.newStartKeyGenerationElement("SHA1").setKeySizeAttribute(20);
// System.out.println("full-path=\""+ path +"\"");
// System.out.println("size=\""+ data.length +"\"");
// System.out.println("checksum=\""+ checksum +"\"");
// System.out.println("compressedData ="+compressedDataLength);