Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this cipher was initialized.
The bytes in the input buffer, and any input bytes that
may have been buffered during a previous update operation,
are processed, with padding (if requested) being applied.
If an AEAD mode such as GCM/CCM is being used, the authentication
tag is appended in the case of encryption, or verified in the
case of decryption.
The result is stored in a new buffer.
Upon finishing, this method 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.
Note: if any exception is thrown, this cipher object may need to be reset before it can be used again.
input | the input buffer |
IllegalStateException | if this cipher is in a wrong state (e.g., has not been initialized) | |
IllegalBlockSizeException | if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size; or if this encryption algorithm is unable to process the input data provided. | |
BadPaddingException | if this cipher is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes | |
AEADBadTagException | if this cipher is decrypting in an AEAD mode (such as GCM/CCM), and the received authentication tag does not match the calculated value |
Diagram: Cipher