Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF

TOPIC:

Does Radaee provide encription 9 years 4 months ago #8047

  • asliyanage
  • asliyanage's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 100
  • Thank you received: 0
I tried with below
byte[] key = "MySecretKeyABCDE".getBytes()
stream.open(path,key);
Then it gives me below error .
The method open(AssetManager, String) in the type PDFAssetStream is not applicable for the arguments (String, byte[])

How to get the AssetManager value to this method ?

Please Log in or Create an account to join the conversation.

Last edit: by Docrishav.

Does Radaee provide encription 9 years 4 months ago #8071

  • asliyanage
  • asliyanage's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 100
  • Thank you received: 0
Hi Radaee ,
Please tell me what is the AssetManager and how do i add this to encryption for pdf ?

Please Log in or Create an account to join the conversation.

Does Radaee provide encription 9 years 4 months ago #8073

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
it is very simple:
//stream from AES
//private PDFAESStream stream = new PDFAESStream();

//stream from AES
//byte[] key = "MySecretKeyABCDE".getBytes();
//stream.open("/sdcard/ttt.pdf", key);
//stream.ImportFromFile("/sdcard/test.pdf");
//stream.ExportToFile("/sdcard/test1.pdf");
//stream.close();
//stream.open("/sdcard/EncryptedCatalog.pdf", key);
//stream.ExportToFile("/sdcard/decrypt.pdf");

Please Log in or Create an account to join the conversation.

Last edit: by .

Does Radaee provide encription 9 years 4 months ago #8075

  • asliyanage
  • asliyanage's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 100
  • Thank you received: 0
Hi Radaee,

Can you explain what each of this line doing as i am confusing both open and ImportFromFile doing same thing?
below are the my imagination for each line.please explain

byte[] key = "MySecretKeyABCDE".getBytes(); = get byte array
//stream.open("/sdcard/ttt.pdf", key); = get the pdf file from sdcard
//stream.ImportFromFile("/sdcard/test.pdf"); = open pdf file from sdcard
//stream.ExportToFile("/sdcard/test1.pdf"); = save the encrypted pdf file
//stream.close(); = close the pdf file
//stream.open("/sdcard/EncryptedCatalog.pdf", key);
//stream.ExportToFile("/sdcard/decrypt.pdf");

Please Log in or Create an account to join the conversation.

Does Radaee provide encription 9 years 4 months ago #8077

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
byte[] key = "MySecretKeyABCDE".getBytes(); // get byte array as key to encryption
stream.open("/sdcard/ttt.pdf", key); //create PDF file as encrypted PDF file.
stream.ImportFromFile("/sdcard/test.pdf"); //load contents, and then encrypt it to ttt.pdf
stream.ExportToFile("/sdcard/test1.pdf"); //decrypt contents, and then export ro test1.pdf, so test1.pdf shall same to test.pdf, this step just for test purpose.
stream.close(); //flush ttt.pdf and close file.

//now open the encrypted PDF file:
byte[] key = "MySecretKeyABCDE".getBytes(); // get byte array as key to encryption
stream.open("/sdcard/ttt.pdf", key);
m_doc.OpenStream(stream);
//to do...
m_doc.Close();

Please Log in or Create an account to join the conversation.

Does Radaee provide encription 9 years 4 months ago #8080

  • asliyanage
  • asliyanage's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 100
  • Thank you received: 0
1)byte[] key = "MySecretKeyABCDE".getBytes(); // get byte array as key to encryption
2)stream.open("/sdcard/ttt.pdf", key); //create PDF file as encrypted PDF file.
3)stream.ImportFromFile("/sdcard/test.pdf"); //load contents, and then encrypt it to ttt.pdf
4)stream.ExportToFile("/sdcard/test1.pdf"); //decrypt contents, and then export ro test1.pdf, so test1.pdf shall same to test.pdf, this step just for test purpose.
5)stream.close(); //flush ttt.pdf and close file

6)stream.open("/sdcard/ttt.pdf", key);
7)m_doc.OpenStream(stream);
8)m_doc.Close();

I tried with above then it gives me below error in 7th line.what is the Sting do i need to add here?


The method OpenStream(Document.PDFStream, String) in the type Document is not applicable for the arguments (PDFAESStream)

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum