IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec);
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);