BcPGPDataEncryptorBuilder
Date: 2016-06-23

org.bouncycastle.openpgp.operator.bc

## Class BcPGPDataEncryptorBuilder

- java.lang.Object
- - org.bouncycastle.openpgp.operator.bc.BcPGPDataEncryptorBuilder

- All Implemented Interfaces:
    PGPDataEncryptorBuilder

      public class BcPGPDataEncryptorBuilder
      extends java.lang.Object
      implements PGPDataEncryptorBuilder

  `PGPDataEncryptorBuilder` implementation that uses the Bouncy Castle lightweight API to implement cryptographic primitives.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BcPGPDataEncryptorBuilder(int encAlgorithm)` Constructs a new data encryptor builder for a specified cipher type.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PGPDataEncryptor` | `build(byte[] keyBytes)` Builds a data encryptor using the algorithm configured for this builder.
    `int` | `getAlgorithm()` The encryption algorithm used by data encryptors created by this builder.
    `java.security.SecureRandom` | `getSecureRandom()` Gets the SecureRandom instance used by this builder.
    `BcPGPDataEncryptorBuilder` | `setSecureRandom(java.security.SecureRandom random)` Provide a user defined source of randomness.
    `BcPGPDataEncryptorBuilder` | `setWithIntegrityPacket(boolean withIntegrityPacket)` Sets whether or not the resulting encrypted data will be protected using an integrity packet.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BcPGPDataEncryptorBuilder

          public BcPGPDataEncryptorBuilder(int encAlgorithm)

      Constructs a new data encryptor builder for a specified cipher type.
      Parameters:
        `encAlgorithm` - one of the `supported symmetric cipher algorithms`. May not be `SymmetricKeyAlgorithmTags.NULL`.

  - ### Method Detail

    - #### setWithIntegrityPacket

          public BcPGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket)

      Sets whether or not the resulting encrypted data will be protected using an integrity packet.
      Parameters:
        `withIntegrityPacket` - true if an integrity packet is to be included, false otherwise.
      Returns:
        the current builder.

    - #### setSecureRandom

          public BcPGPDataEncryptorBuilder setSecureRandom(java.security.SecureRandom random)

      Provide a user defined source of randomness.

      If no SecureRandom is configured, a default SecureRandom will be used.

      Parameters:
        `random` - the secure random to be used.
      Returns:
        the current builder.

    - #### getAlgorithm

          public int getAlgorithm()

      Description copied from interface: `PGPDataEncryptorBuilder`
      The encryption algorithm used by data encryptors created by this builder.
      Specified by:
        `getAlgorithm` in interface `PGPDataEncryptorBuilder`
      Returns:
        one of the `symmetric encryption algorithms`.

    - #### getSecureRandom

          public java.security.SecureRandom getSecureRandom()

      Description copied from interface: `PGPDataEncryptorBuilder`
      Gets the SecureRandom instance used by this builder.
      If a SecureRandom has not been explicitly configured, a default `SecureRandom` is constructed and retained by the this builder.
      Specified by:
        `getSecureRandom` in interface `PGPDataEncryptorBuilder`

    - #### build

          public PGPDataEncryptor build(byte[] keyBytes)
                                 throws PGPException

      Description copied from interface: `PGPDataEncryptorBuilder`
      Builds a data encryptor using the algorithm configured for this builder.
      Specified by:
        `build` in interface `PGPDataEncryptorBuilder`
      Parameters:
        `keyBytes` - the bytes of the key to use for the cipher.
      Returns:
        a data encryptor with an initialised cipher.
      Throws:
        `PGPException` - if an error occurs initialising the configured encryption.