用 qpdf 给 PDF 加密码
在命令行给 PDF 加上用户密码和所有者密码(AES-256 加密)。
运行 qpdf --encrypt 所有者密码 用户密码 256 -- input.pdf output.pdf——读者打开文件时需要输入的"用户密码"。
01命令
命令
$ qpdf --encrypt owner-pass user-pass 256 -- input.pdf output.pdf02作用说明
qpdf 的 --encrypt 需要两个密码:用户密码(打开文件用)和所有者密码(修改权限用)。256 表示使用安全性最高的 AES-256。在密钥长度和 -- 之间还可以加限制参数:--modify=none 禁止编辑,--extract=n 禁止复制文字。想解除加密时,用 qpdf --decrypt 加密码即可导出明文副本。
03风险
!注意: 两个密码都忘了文件就基本救不回来——qpdf 不是破解工具。-- 分隔符必须放在输入文件之前。接收方如果用很老的阅读器,可能需要改用安全性较低的 128 位选项。
04撤销
撤销
$ qpdf --decrypt --password=user-pass output.pdf decrypted.pdf05来源
- qpdf(1) - PDF transformation software依据: qpdf --encrypt user-password owner-password key-length [options] -- infile outfile adds encryption; --decrypt removes it with the correct password.
- qpdf: Encryption — official documentation依据: Documents user vs owner passwords, 256-bit AES encryption and restrictions such as --modify=none and --extract=n.
最后验证: 2026-09-18 · 分类: 媒体