Ghostscript with AES-256 password protection for PDF 2.0 documents

大城市里の小女人 提交于 2021-01-28 11:52:24

问题


A password protected pdf file can be generated with ghostscript:

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=protect.pdf -sOwnerPassword=pwd1 -sUserPassword=pwd2 -dCompatibilityLevel=2.0 test.pdf

The output file has the newest pdf version 2.0 which has unicode support for password protection. But according to pdfinfo the obsolete RC4 algorithm was used:

pdfinfo protect.pdf -upw pwd2
CreationDate: Sat Apr 21 09:10:14 2018 CEST
ModDate: Sat Apr 21 09:10:14 2018 CEST
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 26
Encrypted: yes (print:yes copy:yes change:yes addNotes:yes algorithm:RC4)
Page size: 612 x 792 pts (letter)
Page rot: 0
File size: 288060 bytes
Optimized: no
PDF version: 2.0

According to https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ the PDF 2.0 version is able to encrypt PDF files with the AES-256 standard. How can I do this with ghostscript?


回答1:


The Ghostscript pdfwrite device doesn't support anything except the original RC4 algorithm for encrypting PDF files. The PDF interpreter can decrypt documents using later algorithms.

So as sneep says, you can't do this with Ghostscript and the pdfwrite device.



来源:https://stackoverflow.com/questions/49953421/ghostscript-with-aes-256-password-protection-for-pdf-2-0-documents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!