RadaeePDF.com :: Topic: PDF AES stream (1/2)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC: PDF AES stream

PDF AES stream 3 years 4 months ago #6649

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:
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
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.
The administrator has disabled public write access.

PDF AES stream 3 years 4 months ago #6652

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
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.
The administrator has disabled public write access.

PDF AES stream 3 years 4 months ago #6655

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:
m_file.setLength(0);

m_file is null. I use exactly this 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.
The administrator has disabled public write access.

PDF AES stream 3 years 4 months ago #6658

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
sorry, forgot something.
codes:
PDFAESStream stream = new PDFAESStream();
stream.open( outputPath, password );
stream.ImportFromFile(inputPath);
stream.close();
The administrator has disabled public write access.

PDF AES stream 3 years 4 months ago #6660

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.
The administrator has disabled public write access.

PDF AES stream 3 years 4 months ago #6663

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
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: 3 years 4 months ago by .
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Powered by Kunena Forum