For encryption we use pdfenc based on itext. Many thanks to Steven Lee.

****************************************
PDFEncryptor 1.1,all right reserved!
allows you to encrypt (using standard 40-bit or
128-bit supported by Acrobat Reader 5.0 and up) existing PDFs
Author:Steven Lee
HomePage:http://www.rocsky.com
Email:asksteven@qianlong.com
There is no warranty.
Please use at your own risk.
It is free,but any donation is welcome.
If you notice any bugs please let me know
by email at asksteven@qianlong.com
****************************************