Giter Club home page Giter Club logo

Comments (3)

galkahana avatar galkahana commented on July 20, 2024

Cant. Hummus does not read or write encrypted files

from pdf-writer.

stribor avatar stribor commented on July 20, 2024

That is what I seen from sources. I meant any pointers in how to extend it to support it.

I started read up pdf documentation on encryption (even found small round up of it https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt )

It seem only thing needed is adding encrypt dictionary plus encrypting all streams while writing them.
Assuming I manage to create this encrypt dictionary get encryption algo right.
And I guess it wouldn't be that hard to pass all stream writes to de/encryption function before reading/writing them?

I still need to read up on encryption part of pdf and than to figure out how easy would it be to add it to PDF-Writter.

So far I only need writing encrypted pdfs and I'll have either to hack in encryption in or look up another library. So I hopped for some input to make hacking it in easier :)

Greetings

from pdf-writer.

galkahana avatar galkahana commented on July 20, 2024

As far as my understanding goes encrypting encrypts all strings and streams.

For writing, you should look into ObjectsContext.h which takes care of writing the basic PDF elements.
For instance, implementing encryption when writing strings can be done by modifying the string writing methods of this class.
For streams writing just implement the encryption through a new IByteWriterWithPosition that does encryption and add it in the PDFStream constructor. i do that already for flate, so adding something similar for encryption should work well (just figure out which goes on top of which :) and also do this for unfiltered streams).

adding the relevant dictionaries should be done on the catalog and you can look into DocumentContext class to see where the catalog is written in endpdf.

For reading it's kind of simpler cause all goes through PDFParser. check where strings are being read and add also relevant code for the stream reading helper. seems like i did have something in mind for reading encrypted files, because i have this mParserExtender member in the parser which is an optional extender that you can add to implement the relevant reading helpers in case a file is encrypted. i suggest you follow its methods.

hopefully this should cover all usages and provide you with a working implementation.

from pdf-writer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.