public class BcPGPDataEncryptorBuilder extends java.lang.Object implements PGPDataEncryptorBuilder
PGPDataEncryptorBuilder
implementation that uses the Bouncy Castle lightweight API to
implement cryptographic primitives.Constructor and Description |
---|
BcPGPDataEncryptorBuilder(int encAlgorithm)
Constructs a new data encryptor builder for a specified cipher type.
|
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.
|
public BcPGPDataEncryptorBuilder(int encAlgorithm)
encAlgorithm
- one of the supported symmetric cipher
algorithms
. May not be SymmetricKeyAlgorithmTags.NULL
.public BcPGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket)
withIntegrityPacket
- true if an integrity packet is to be included, false otherwise.public BcPGPDataEncryptorBuilder setSecureRandom(java.security.SecureRandom random)
If no SecureRandom is configured, a default SecureRandom will be used.
random
- the secure random to be used.public int getAlgorithm()
PGPDataEncryptorBuilder
getAlgorithm
in interface PGPDataEncryptorBuilder
symmetric encryption algorithms
.public java.security.SecureRandom getSecureRandom()
PGPDataEncryptorBuilder
SecureRandom
is
constructed and retained by the this builder.getSecureRandom
in interface PGPDataEncryptorBuilder
public PGPDataEncryptor build(byte[] keyBytes) throws PGPException
PGPDataEncryptorBuilder
build
in interface PGPDataEncryptorBuilder
keyBytes
- the bytes of the key to use for the cipher.PGPException
- if an error occurs initialising the configured encryption.