CryptoException.ILLEGAL_VALUE if theMode option is an undefined value
or if a byte array parameter option is not supported by the algorithm or if
the bLen is an incorrect byte length for the algorithm specific data or
if the Key is inconsistent with the Cipher implementation.

CryptoException.UNINITIALIZED_KEY if theKey instance is uninitialized.

doFinal

Generates encrypted/decrypted output from all/last input data. This method must be invoked
to complete a cipher operation. This method processes any remaining input data buffered by
one or more calls to the update() method as well as input data supplied in the
inBuff parameter.

A call to this method also resets this Cipher object to the state it was in
when previously initialized via a call to init().
That is, the object is reset and available to encrypt or decrypt
(depending on the operation mode that was specified in the call to init()) more data.
In addition, note that the initial vector(IV) used in AES and DES algorithms will be reset to 0.

Notes:

When using block-aligned data (multiple of block size),
if the input buffer, inBuff and the output buffer,
outBuff
are the same array, then the output data area must not partially overlap the input data area such that
the input data is modified before it is used;
if inBuff==outBuff andinOffset < outOffset < inOffset+inLength,
incorrect output may result.

When non-block aligned data is presented as input data, no amount of input
and output buffer data overlap is allowed;
if inBuff==outBuff andoutOffset < inOffset+inLength,
incorrect output may result.

AES, DES, and triple DES algorithms in CBC mode reset the initial vector(IV)
to 0. The initial vector(IV) can be re-initialized using the
init(Key, byte, byte[], short, short) method.

On decryption operations (except when ISO 9797 method 1 padding is used),
the padding bytes are not written to outBuff.

On encryption and decryption operations, the number of bytes output into outBuff
may be larger or smaller than inLength or even 0.

On decryption operations resulting in an ArrayIndexOutOfBoundException,
outBuff may be partially modified.

This method requires temporary storage of
intermediate results. In addition, if the input data length is not block aligned
(multiple of block size)
then additional internal storage may be allocated at this time to store a partial
input data block.
This may result in additional resource consumption and/or slow performance.

This method should only be used if all the input data required for the cipher
is not available in one byte array. If all the input data required for the cipher
is located in a single byte array, use of the doFinal() method to
process all of the input data is recommended. The doFinal() method
must be invoked to complete processing of any remaining input data buffered by one or more calls
to the update() method.

Notes:

When using block-aligned data (multiple of block size),
if the input buffer, inBuff and the output buffer,
outBuff
are the same array, then the output data area must not partially overlap the input data area such that
the input data is modified before it is used;
if inBuff==outBuff andinOffset < outOffset < inOffset+inLength,
incorrect output may result.

When non-block aligned data is presented as input data, no amount of input
and output buffer data overlap is allowed;
if inBuff==outBuff andoutOffset < inOffset+inLength,
incorrect output may result.

On decryption operations(except when ISO 9797 method 1 padding is used),
the padding bytes are not written to outBuff.

On encryption and decryption operations,
block alignment considerations may require that
the number of bytes output into outBuff be larger or smaller than
inLength or even 0.