We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

A very long save time with password

Hello,
We are using aspose words for java version 19.3 with java 8 environment.
I noticed that when trying to encrypt a document the save time is very long and random.
Sometime its a second and sometimes its 5 minutes.
I ran the following code 3 times:

private void testEnc(int attempt) {
	System.out.println("attempt: " + attempt);
	String pass = "12345";
	try {
		
		System.out.println("load start: " + new Date().toString());
		Document doc = new Document("/tmp/enc.docx");
		System.out.println("load end: " + new Date().toString());
		
		
		OoxmlSaveOptions sa = new OoxmlSaveOptions();
		sa.setPassword(pass);
		System.out.println("save start: " + new Date().toString());
		doc.save("/tmp/enc" + attempt + ".docx", sa);
		System.out.println("save end: " + new Date().toString());
		
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

with the following output:
attempt: 1
load start: Sun Mar 24 13:14:01 IST 2019
load end: Sun Mar 24 13:14:02 IST 2019
save start: Sun Mar 24 13:14:02 IST 2019
save end: Sun Mar 24 13:15:20 IST 2019
attempt: 2
load start: Sun Mar 24 13:15:20 IST 2019
load end: Sun Mar 24 13:15:20 IST 2019
save start: Sun Mar 24 13:15:20 IST 2019
save end: Sun Mar 24 13:17:00 IST 2019
attempt: 3
load start: Sun Mar 24 13:17:00 IST 2019
load end: Sun Mar 24 13:17:00 IST 2019
save start: Sun Mar 24 13:17:00 IST 2019
save end: Sun Mar 24 13:18:35 IST 2019
As you can see its 1:18 for 1st attempt, 1:40 for the second and 2:35 for the third.
The enc.docx document is almost empty contains only one sentence.enc_problem.zip (7.3 KB)
I uploaded the tested document.

Execute it several times because as I said it is random and it can work either fast or get stuck forever.

@arik-1

We are investigating your issue and will get back to you soon.

@arik-1

We have tested the scenario at Windows 10 and Java 8. We have not face the shared issue at our end. This test case takes around 300 to 400 milliseconds at our end. Please make sure that you have set the license before executing testEnc method.

The license was set properly before the tests. However, I was testing it on Ubuntu.

@arik-1

Thanks for sharing the detail. We will investigate this issue at Ubuntu operating system and will share our findings with you as soon as possible.

@arik-1

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSJAVA-2017. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@arik-1

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSJAVA-2017) as ‘Not a Bug’.

The problem inside java.security.SecureRandom.generateSeed. SecureRandom is involved in the encryption/decryption process and uses NativePRNG which, in its turn, simply opens the FileInputStream (/dev/random) and reads the value.

The problem is /dev/random is a blocking algorithm. One of the possible solutions would be to use a non-blocking algorithm which is /dev/urandom.

In order to use it, please try the following VM argument
-Djava.security.egd=file:/dev/urandom