Preferred compression for pgp data in Java

By default DidiSoft OpenPGP Library for Java uses ZIP compression when encrypting and signing data.

This can be changed through the method PGPLib.setCompression(compression). The supported options are listed in the CompressionAlgorithm interface:


The change has effect on subsequent calls to the encryption methods only on the current instance of the PGPLib object. For each new instance the preferred compression should be set explicitly.

The example below shows how to set the compression to ZLib:

import com.didisoft.pgp.CompressionAlgorithm;
import com.didisoft.pgp.PGPLib;
public class SetCompressionDemo {
  public static void main(String[] args) throws Exception {
	PGPLib pgp = new PGPLib();
        // each subsequent encryption will use ZLib

<< Back to Examples