If I take an encrypted Word document, and then decrypt it using Aspose, I think it’s reasonable to expect Aspose to produce the same file every time.
However, this is not the case.
Test program:
private final Path dir = Paths.get("/Users/Daniel/Downloads/decryption time");
@Test
public void test1() throws Exception
{
System.setSecurityManager(null);
DateTimeZone zone = DateTimeZone.forID("Australia/Sydney");
System.out.println("Time zone: " + zone);
DateTimeZone.setDefault(zone);
TimeZone.setDefault(zone.toTimeZone());
try (InputStream stream = Files.newInputStream(dir.resolve("encrypted.doc")))
{
Document asposeDocument = new Document(stream, new LoadOptions("password"));
System.out.println("Created time: " + asposeDocument.getBuiltInDocumentProperties().getCreatedTime());
asposeDocument.unprotect();
Path decryptedFile = dir.resolve("decrypted-sydney.doc");
asposeDocument.save(decryptedFile.toString());
System.out.println("File digest: " + Arrays.toString(MessageDigest.getInstance("MD5").digest(Files.readAllBytes(decryptedFile))));
}
}
@Test
public void test2() throws Exception
{
System.setSecurityManager(null);
DateTimeZone zone = DateTimeZone.forID("Asia/Tokyo");
System.out.println("Time zone: " + zone);
DateTimeZone.setDefault(zone);
TimeZone.setDefault(zone.toTimeZone());
try (InputStream stream = Files.newInputStream(dir.resolve("encrypted.doc")))
{
Document asposeDocument = new Document(stream, new LoadOptions("password"));
System.out.println("Created time: " + asposeDocument.getBuiltInDocumentProperties().getCreatedTime());
asposeDocument.unprotect();
Path decryptedFile = dir.resolve("decrypted-tokyo.doc");
asposeDocument.save(decryptedFile.toString());
System.out.println("File digest: " + Arrays.toString(MessageDigest.getInstance("MD5").digest(Files.readAllBytes(decryptedFile))));
}
}
When I run test1:
Time zone: Australia/Sydney
Created time: Mon Jul 04 15:03:00 AEST 2016
File digest: [33, -19, -22, 81, 59, 112, -94, 44, 117, 111, 92, 98, 7, 45, -68, 7]
When I run test2:
Time zone: Asia/Tokyo
Created time: Mon Jul 04 14:03:00 JST 2016
File digest: [-71, 37, 3, 34, 117, 100, -21, -104, -122, -64, -40, 35, 116, -106, -69, 61]
The difference in the files shows Aspose stamping in two date values:
bucket:decryption time daniel$ diff decrypted-sydney.doc.txt decrypted-tokyo.doc.txt
3522c3522
< 0000e030 f0 d0 02 00 00 68 01 00 00 00 00 c3 23 47 27 c5 |.....h......#G'.|
---
> 0000e030 f0 d0 02 00 00 68 01 00 00 00 00 83 23 47 27 85 |.....h......#G'.|
(The next line starts with 23 47 27.)
Decoding the values, we see that in Sydney, it is using Mon Jul 04 2016 15:03:10 for creation time and Mon Jul 04 2016 15:05:00 for last modified, but for Tokyo, it is using Mon Jul 04 2016 14:03:00 for creation time and Mon Jul 04 2016 14:05:00 for last modified.
I believe these two values should have the same hour value, because the file itself would have stored the local time, not the UTC time. So Aspose must be either reading the wrong value when reading the date from the original, or writing the wrong data when writing the date to the destination.
I wasn’t able to check stuff any further than that.