Skip to main content

EncryptionAlgorithm Enum

Lists values that specify the encryption algorithm.

Declaration

public enum EncryptionAlgorithm extends Enum<EncryptionAlgorithm> implements IIntEnum

Members

Name Description
AES_128

128-bit AES (Advanced Encryption Standard)

AES_256

256-bit AES (Advanced Encryption Standard)

fromValue(int value)

Returns the enum item with the specified integer value.

getName()

Returns the enum item name.

getValue()

Returns the integer value.

toString()

Returns the string representation.

valueOf(String name)

Returns the enum constant with the specified name.

values()

Returns available constants.

Remarks

Use the EncryptionOptions.setAlgorithm() method to specify the encryption algorithm.

The following code snippet loads a PDF document, encrypts it, restricts specific operations, and saves the result:

import com.devexpress.docs.pdf.*;

import java.nio.file.*;
import java.nio.channels.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileChannel channel = FileChannel.open(Path.of("Document.pdf"));
             PdfDocument pdfDocument = new PdfDocument(channel)) {

            EncryptionOptions encryptionOptions = new EncryptionOptions(
                    "ownerPassword", 
                    "userPassword"
            ) {{

                    setDataExtractionPermissions(DocumentDataExtractionPermissions.NOT_ALLOWED);
                    setPrintPermissions(DocumentPrintPermissions.LOW_QUALITY);
                    setModificationPermissions(DocumentModificationPermissions.NOT_ALLOWED);
                    setAlgorithm(EncryptionAlgorithm.AES_256);
                }};

            pdfDocument.encrypt(encryptionOptions);

            // Save the encrypted document.
            try (WritableByteChannel writableByteChannel =
                 FileChannel.open(Path.of("Document_encrypted.pdf"),
                     StandardOpenOption.CREATE,
                     StandardOpenOption.WRITE,
                     StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(writableByteChannel);
            }
        }
    }
}

Refer to the following help topic for additional information: Encrypt PDF Documents.

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
java.lang.Enum
EncryptionAlgorithm