Class PdfEncryption


  • public class PdfEncryption
    extends Object
    Author:
    Paulo Soares, Kazuya Ujihara
    • Constructor Detail

      • PdfEncryption

        public PdfEncryption()
    • Method Detail

      • setCryptoMode

        public void setCryptoMode​(int mode,
                                  int kl)
      • getCryptoMode

        public int getCryptoMode()
      • isMetadataEncrypted

        public boolean isMetadataEncrypted()
      • getPermissions

        public long getPermissions()
      • isEmbeddedFilesOnly

        public boolean isEmbeddedFilesOnly()
        Indicates if only the embedded files have to be encrypted.
        Returns:
        if true only the embedded files will be encrypted
        Since:
        2.1.3
      • setupAllKeys

        public void setupAllKeys​(byte[] userPassword,
                                 byte[] ownerPassword,
                                 int permissions)
      • createDocumentId

        public static byte[] createDocumentId()
      • setupByUserPassword

        public void setupByUserPassword​(byte[] documentID,
                                        byte[] userPassword,
                                        byte[] ownerKey,
                                        long permissions)
      • setupByOwnerPassword

        public void setupByOwnerPassword​(byte[] documentID,
                                         byte[] ownerPassword,
                                         byte[] userKey,
                                         byte[] ownerKey,
                                         long permissions)
      • setKey

        public void setKey​(byte[] key)
      • setupByEncryptionKey

        public void setupByEncryptionKey​(byte[] key,
                                         int keylength)
      • setHashKey

        public void setHashKey​(int number,
                               int generation)
      • getEncryptionDictionary

        public PdfDictionary getEncryptionDictionary()
      • calculateStreamSize

        public int calculateStreamSize​(int n)
      • encryptByteArray

        public byte[] encryptByteArray​(byte[] b)
      • decryptByteArray

        public byte[] decryptByteArray​(byte[] b)
      • addRecipient

        public void addRecipient​(Certificate cert,
                                 int permission)
      • computeUserPassword

        public byte[] computeUserPassword​(byte[] ownerPassword)
        Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 algorithm (Revision 2 - 4).
        Parameters:
        ownerPassword - owner password of the encrypted document.
        Returns:
        user password, or null if revision 5 (AES256) or greater of standard encryption handler was used.