简体   繁体   English

如何判断上传到我的applet的PDF是否已加密?

[英]How can I tell if a PDF uploaded to my applet is encrypted?

I want to know if a PDF document uploaded to my applet is encrypted. 我想知道上传到我的applet的PDF文档是否已加密。 Being an applet I don't want to have the whole of PDFBox (which does this) with my applet so I'm looking for something smaller or the code for doing this directly! 作为一个小程序我不想让我的小程序拥有整个PDFBox(这样做)所以我正在寻找更小的东西或直接执行此操作的代码!

I am trying to go through the code for PDFBox to strip out just the necessary code but not sure if this is WAY too much work or even if it violates the licence. 我试图通过PDFBox的代码去除必要的代码,但不确定这是否是太多的工作,或者即使它违反了许可证。

Ok, looks like I was a better-off looking for the format of a PDF document than for any library: 好吧,看起来我是一个更好的寻找PDF文档的格式而不是任何库:

FYI: PDFs have an ending called a "trailer" which goes something like this: 仅供参考:PDF文件有一个名为“预告片”的结尾,如下所示:

trailer
<< /Size 196 /Root 65 0 R /Encrypt 195 0 R /Info 1 0 R /ID [ > <5daebb80fcf4c7d4329e8cf5043af186> <5daebb80fcf4c7d4329e8cf5043af186> ] >>
startxref
300552
%%EOF

If encrypt is there, the document is encrypted (no reference for this but that's how PDFBox handles it and stands up to a few tests on encrypted and not encrypted PDFs. 如果加密,那么文档是加密的(没有参考,但这是PDFBox处理它的方式,并且可以对加密和未加密的PDF进行一些测试。

This is a good basic introduction: 这是一个很好的基本介绍:

http://resources.infosecinstitute.com/pdf-file-format-basic-structure/ http://resources.infosecinstitute.com/pdf-file-format-basic-structure/

For the full spec look here 这里有完整的规格

http://www.adobe.com/devnet/pdf/pdf_reference.html http://www.adobe.com/devnet/pdf/pdf_reference.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM