Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

PDF AES stream

More
IP: 192.168.0.71 11 years 8 months ago #6649 by petr.sklenicka
Hello,
I have a problem with using of a class PDFAESStream. I have an encrypted book and I'm trying to open it. For this purpose I use this code:
Code:
PDFAESStream stream = new PDFAESStream(); stream.open(bookPath, "MySecretKeyABCDE".getBytes());

The bookPath variable is an existing path to the book, which is encrypted via AES.
The open() method always returns false. For encryption, I simply used AES/CBC/PKCS5Padding. The open() method still returns false, because the condition
Code:
if( m_enc_len % BLOCK_ENC_SIZE != 4 ) // Line from your code

is always true.

Where is the problem?
Thank you in advance for your reply.
More
IP: 192.168.0.71 11 years 8 months ago #6652 by radaee
Replied by radaee on topic PDF AES stream
PDFAESStream is customer format file.
you shall use PDFAESStream.ImportFromFile() to create a encrypted PDF file.

to create encrypted PDF file codes like:
PDFAESStream stream = new PDFAESStream();
stream.ImportFromFile( "path-name" );
stream.ExportToFile( "an other path-name" );
stream.close();

to open encrypted PDF file codes like:
PDFAESStream stream = new PDFAESStream();
stream.open( "path_name", password );
Document doc = new Document();
doc.OpenStream( stream, ... );
doc.Close();
stream.close();

PDFAESStream may used in pure java envirment on linux/windows and so on.
More
IP: 192.168.0.71 11 years 8 months ago #6655 by petr.sklenicka
Replied by petr.sklenicka on topic PDF AES stream
Ok, thank you for your reply.

I tried your code, but it does not work. A method ImportFromFile returns false. The problem is with this line:
Code:
m_file.setLength(0);

m_file is null. I use exactly this code:
Code:
PDFAESStream stream = new PDFAESStream(); stream.ImportFromFile(inputPath); stream.ExportToFile(outputPath); stream.close();

The variable inputPath is path of the book and this path exists.
More
IP: 192.168.0.71 11 years 8 months ago #6658 by radaee
Replied by radaee on topic PDF AES stream
sorry, forgot something.
codes:
Code:
PDFAESStream stream = new PDFAESStream(); stream.open( outputPath, password ); stream.ImportFromFile(inputPath); stream.close();
More
IP: 192.168.0.71 11 years 8 months ago #6660 by petr.sklenicka
Replied by petr.sklenicka on topic PDF AES stream
This code works. It creates a new file with length 4096 bytes. Is this correct? I thought that it will create a new file - the encrypted PDF document with AES.
More
IP: 192.168.0.71 11 years 8 months ago - 11 years 8 months ago #6663 by radaee
Replied by radaee on topic PDF AES stream
there are example in ReaderActivity.java
some codes are commented.
//byte key[] = new byte[16];
//stream.open("/sdcard/ttt.pdf", key);
//stream.ImportFromFile("/sdcard/test.pdf"); //encrypt to /sdcard/ttt.pdf
//stream.ExportToFile("/sdcard/test1.pdf"); //decrypt to /sdcard/test1.pdf

these codes shall tested.
Last edit: 11 years 8 months ago by .
Time to create page: 0.435 seconds
Powered by Kunena Forum