Class BasicCryptor

  • All Implemented Interfaces:
    Cryptor
    Direct Known Subclasses:
    SymmetricCryptor

    public class BasicCryptor
    extends Object
    implements Cryptor

    Public methods in this class throw only CryptoExceptions.

    • Field Detail

      • decryptKey

        protected Key decryptKey
        The key to be used for decryption.
      • encryptCipher

        protected Cipher encryptCipher
        The Cipher to use for encryption.
      • cipherAlgorithm

        protected String cipherAlgorithm
    • Method Detail

      • setUseSealedObject

        public void setUseSealedObject​(boolean useSealedObject)
      • setClassLoader

        public void setClassLoader​(ClassLoader classLoader)
      • decrypt

        public byte[] decrypt​(byte[] ciphertext)
                       throws CryptoException
        Decrypt the ciphertext to yield the original cleartext.
        Specified by:
        decrypt in interface Cryptor
        Parameters:
        ciphertext - The text to be encrypted, in byte form
        Returns:
        The decrypted cleartext, in byte form
        Throws:
        CryptoException
      • initDecryptCipher

        protected void initDecryptCipher()
                                  throws CryptoException
        Initialize the ciphers used for encryption and decryption. The ciphers define the algorithms to be used. They are initialized with the appropriate key to be used in the encryption or decryption operation.
        Throws:
        CryptoException
      • encrypt

        public byte[] encrypt​(byte[] cleartext)
                       throws CryptoException
        Encrypt the cleartext in byte array format.
        Specified by:
        encrypt in interface Cryptor
        Parameters:
        cleartext - The text to be encrypted, in byte form
        Returns:
        The encrypted ciphertext, in byte form
        Throws:
        CryptoException
      • initEncryptCipher

        protected void initEncryptCipher()
                                  throws CryptoException
        Initialize the cipher used for encryption. The cipher defines the algorithm to be used. It is initialized with the appropriate key to be used in the encryption operation.
        Throws:
        CryptoException