-4

I have a pdf or word file, and read it in bytes, so I can encrypted it, now, I want to know how can I write these bytes to pdf file, so user see it as Garbage codes unless the file was decrypted?

Is there a method to change each page to bytes? I need c or c++ code. Because I want to encrypt each pdf page, and I can encrypt bytes data, also I want to know when I encrypt each page, is it still a pdf file, and just each page is Garbage characters(unreadable codes, messy code).

Drise
  • 4,310
  • 5
  • 41
  • 66
Tony Stark
  • 174
  • 1
  • 4

3 Answers3

1

The PDF specification already describes PDF encryption: encrypted PDF objects are removed from the top level and instead contained within an object stream (another object, with /Type /ObjStm) encrypted with /Filter /Crypt.

ephemient
  • 198,619
  • 38
  • 280
  • 391
0

It already is bytes - it is how you interpret the bytes that matter!

With a bit of knowledge about PDF format you could write something to encrypt a file such that it was still PDF but appears as unreadable garbage*, but if you just encrypt the PDF file (or bytes in it), then it won't still be a PDF file.

* This is just an assumption - I haven't actually done it myself.

John3136
  • 28,809
  • 4
  • 51
  • 69
  • It is a great solution, yeah, I am just finding a open source lib for write pdf file, just as you said, write encrypted bytes as a pdf file, dou you know any libs? – Tony Stark Jul 23 '12 at 01:58
  • Sorry, I've not written PDFs programatically. – John3136 Jul 23 '12 at 02:12
-1

This post provides useful libraries to create pdf. Before writing the pdf to file you should be able to encrypt the text.

Community
  • 1
  • 1
A. K.
  • 34,395
  • 15
  • 52
  • 89