Interface EncryptionAlgorithm

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte[] decrypt​(byte[] ciphertext)
      Decrypts the given ciphertext bytes into a byte array of plaintext using the decryption key.
      void decrypt​(InputStream in, OutputStream out)
      Decrypts the data in the given ciphertext input stream into plaintext in the output stream.
      byte[] decrypt​(String ciphertext, Converter converter)
      Decrypts a string representation of ciphertext bytes into a byte array of plaintext using the decryption key.
      byte[] encrypt​(byte[] plaintext)
      Encrypts the given plaintext bytes into a byte array of ciphertext using the encryption key.
      String encrypt​(byte[] plaintext, Converter converter)
      Encrypts the given plaintext bytes into a ciphertext string using the conversion strategy provided by the given converter.
      void encrypt​(InputStream in, OutputStream out)
      Encrypts the data in the given plaintext input stream into ciphertext in the output stream.
      int getBlockSize()
      Gets the block size of the encryption algorithm cipher in bytes.
      int getCipherMode()
      Gets the cipher mode indicating whether this instance is currently initialized for encryption or decryption.
      String getMode()
      Gets the encryption mode.
      String getPadding()
      Gets the encryption padding method.
      void initDecrypt()
      Initializes this instance for decryption operations.
      void initEncrypt()
      Initializes this instance for encryption operations.
      void setKey​(Key k)
      Sets the key used for encryption/decryption.
    • Method Detail

      • getMode

        String getMode()
        Gets the encryption mode.
        Returns:
        Name of an encryption mode, e.g. CBC.
      • getPadding

        String getPadding()
        Gets the encryption padding method.
        Returns:
        Name of a padding method, e.g. PKCS5Padding.
      • setKey

        void setKey​(Key k)
        Sets the key used for encryption/decryption.
        Parameters:
        k - Public, private, or secret key used for encryption or decryption.
      • getBlockSize

        int getBlockSize()
        Gets the block size of the encryption algorithm cipher in bytes.
        Returns:
        Block size of cipher in bytes, or 0 if the cipher is not a block cipher.
      • initEncrypt

        void initEncrypt()
                  throws CryptException
        Initializes this instance for encryption operations.
        Throws:
        CryptException - On cryptographic configuration errors.
      • initDecrypt

        void initDecrypt()
                  throws CryptException
        Initializes this instance for decryption operations.
        Throws:
        CryptException - On cryptographic configuration errors.
      • encrypt

        byte[] encrypt​(byte[] plaintext)
                throws CryptException
        Encrypts the given plaintext bytes into a byte array of ciphertext using the encryption key.
        Parameters:
        plaintext - Input plaintext bytes.
        Returns:
        Ciphertext resulting from plaintext encryption.
        Throws:
        CryptException - On encryption errors.
      • encrypt

        String encrypt​(byte[] plaintext,
                       Converter converter)
                throws CryptException
        Encrypts the given plaintext bytes into a ciphertext string using the conversion strategy provided by the given converter.
        Parameters:
        plaintext - Input plaintext bytes.
        converter - Converter that converts ciphertext output bytes to a string representation.
        Returns:
        Ciphertext string resulting from plaintext encryption.
        Throws:
        CryptException - On encryption errors.
      • decrypt

        byte[] decrypt​(byte[] ciphertext)
                throws CryptException
        Decrypts the given ciphertext bytes into a byte array of plaintext using the decryption key.
        Parameters:
        ciphertext - Input ciphertext bytes.
        Returns:
        Plaintext resulting from ciphertext decryption.
        Throws:
        CryptException - On decryption errors.
      • decrypt

        byte[] decrypt​(String ciphertext,
                       Converter converter)
                throws CryptException
        Decrypts a string representation of ciphertext bytes into a byte array of plaintext using the decryption key.
        Parameters:
        ciphertext - Input ciphertext bytes.
        converter - Converter that converts the ciphertext input string into raw bytes required by the cipher algorithm.
        Returns:
        Plaintext resulting from ciphertext decryption.
        Throws:
        CryptException - On decryption errors.