|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
SymmetricCipher defines an interface for encrypting and
decrypting data based on symmetric algorithms. Implementations may use
a secret key, public/private key, etc. as required.
| Method Summary | |
byte[] |
decrypt(byte[] input)
Decrypts data in a single-part operation. |
int |
decrypt(byte[] input,
int inputLen,
byte[] output)
Decrypts data in a single-part operation. |
byte[] |
encrypt(byte[] input)
Encrypts data in a single-part operation. |
int |
encrypt(byte[] input,
int inputLen,
byte[] output)
Encrypts data in a single-part operation. |
| Method Detail |
public byte[] encrypt(byte[] input)
throws IllegalStateException,
IllegalBlockSizeException,
BadPaddingException
The bytes in the input buffer are processed and padded if necessary. The result is stored in a new buffer.
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
BadPaddingException - if the internal encryption cipher has
and invalid padding configuration or has an error while padding data.
public int encrypt(byte[] input,
int inputLen,
byte[] output)
throws IllegalStateException,
IllegalBlockSizeException,
ShortBufferException,
BadPaddingException
The specified number of bytes in the input buffer are processed and padded if necessary. The result is stored in the specified output buffer. NOTE: this method should be used in preference to methods that return new byte buffers when multiple encrptions must be performed within the scope of a calling method. This enables reuse of the output buffer for returned encrypted cipher text.
input - the input buffer (the clear text)inputLen - the number of bytes to be read from the input bufferoutput - the output buffer (for storing cipher text)
IllegalStateException - if this cipher is in a wrong state
(e.g., has not been initialized)
ShortBufferException - if the given output buffer is too small
to hold the result
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
BadPaddingException - if the internal encryption cipher has
and invalid padding configuration or has an error while padding data.
public byte[] decrypt(byte[] input)
throws IllegalStateException,
IllegalBlockSizeException,
BadPaddingException
The bytes in the input buffer are processed and padding that was added at encryption time is removed. The result is stored in a new buffer.
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
BadPaddingException - if the internal encryption cipher has
and invalid padding configuration or has an error while padding data.
public int decrypt(byte[] input,
int inputLen,
byte[] output)
throws IllegalStateException,
IllegalBlockSizeException,
ShortBufferException,
BadPaddingException
The specified number of bytes in the input buffer are processed and padding is removed. The result is stored in the specified output buffer. NOTE: this method should be used in preference to methods that return new byte buffers when multiple decryptions must be performed within the scope of a calling method. This enables reuse of the output buffer for returned decrypted clear text.
input - the input buffer (the cipher text)inputLen - the number of bytes to be read from the input bufferoutput - the output buffer (for storing clear text)
IllegalStateException - if this cipher is in a wrong state
(e.g., has not been initialized)
ShortBufferException - if the given output buffer is too small
to hold the result
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
BadPaddingException - if the internal encryption cipher has
and invalid padding configuration or has an error while padding data.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||