Class CipherFactory


  • public class CipherFactory
    extends java.lang.Object
    Factory methods for creating Cipher objects and CipherOutputStreams.
    • Constructor Detail

      • CipherFactory

        public CipherFactory()
    • Method Detail

      • createContentCipher

        public static java.lang.Object createContentCipher​(boolean forEncryption,
                                                           CipherParameters encKey,
                                                           AlgorithmIdentifier encryptionAlgID)
                                                    throws java.lang.IllegalArgumentException
        Create a content cipher for encrypting bulk data.
        Parameters:
        forEncryption - true if the cipher is for encryption, false otherwise.
        encKey - the basic key to use.
        encryptionAlgID - identifying algorithm OID and parameters to use.
        Returns:
        a StreamCipher or a BufferedBlockCipher depending on the algorithm.
        Throws:
        java.lang.IllegalArgumentException
      • createOutputStream

        public static CipherOutputStream createOutputStream​(java.io.OutputStream dOut,
                                                            java.lang.Object cipher)
        Return a new CipherOutputStream based on the passed in cipher.
        Parameters:
        dOut - the output stream to write the processed data to.
        cipher - the cipher to use.
        Returns:
        a BC CipherOutputStream using the cipher and writing to dOut.