Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is a "good" tool to encrypt (password protect) .pdf files? (without being required to buy additional software; the protection can be created under linux but the password query should work on Windows, too)

I know that zip can do it: zip zipfile_name_without_ending -e files_to_encrypt.foo What I don't like about this is that for a single file, you have to use Winzip to open the zip and then click the file again. I rather would like to be prompted for a password when opening the .pdf (single file case). I know that pdftk can do this: pdftk foo.pdf output foo_protected.pdf user_pw mypassword. The problem here is that the password is displayed in the terminal -- even if you use ... user_pw PROMPT. But in the end you get a password-protected .pdf and you are prompted for the password when opening the file.

share|improve this question
up vote 2 down vote accepted

You could just wrap pdftk in a script. Something as

#!/bin/bash

filename=$1
base_filename=${filename%pdf}
new_filename=$(echo $base_filename"encrypted.pdf")

read -p 'password:' -s secret; echo
pdftk $filename output $new_filename user_pw $secret

echo ${filename}" encrypted to "${new_filename}

Of course you should add some checking and you could give both input and output file names, etc, but you get the point.

share|improve this answer
    
nice idea, thanks! I still hope for a different solution since pdftk is old and not well maintained anymore (afaik). – Marius Hofert Jun 21 '12 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .