public abstract class Cipher
extends java.lang.Object
update.  Finally,
 doFinal is called to finalize the operation. Note that
 it is not necessary to call update if all of the data is
 available at once.  In this case, all of the input can be processed with one
 call to doFinal.| Constructor and Description | 
|---|
Cipher()  | 
| Modifier and Type | Method and Description | 
|---|---|
abstract byte[] | 
doFinal()
Completes an cipher operation. 
 | 
abstract byte[] | 
doFinal(byte[] bytes)
Completes an cipher operation. 
 | 
abstract byte[] | 
doFinal(byte[] bytes,
       int offset,
       int length)
Completes an cipher operation. 
 | 
abstract void | 
initDecrypt(SymmetricKey key)
Initializes a decryption context with a symmetric key. 
 | 
abstract void | 
initDecrypt(SymmetricKey key,
           java.security.spec.AlgorithmParameterSpec parameters)
Initializes a decryption context with a symmetric key and
 algorithm parameters. 
 | 
abstract void | 
initEncrypt(SymmetricKey key)
Initializes a encryption context with a symmetric key. 
 | 
abstract void | 
initEncrypt(SymmetricKey key,
           java.security.spec.AlgorithmParameterSpec parameters)
Initializes an encryption context with a symmetric key and
 algorithm parameters. 
 | 
static byte[] | 
pad(byte[] toBePadded,
   int blockSize)
Pads a byte array so that its length is a multiple of the given
  blocksize. 
 | 
static byte[] | 
unPad(byte[] padded)
Un-pads a byte array that is padded with PKCS padding. 
 | 
static byte[] | 
unPad(byte[] padded,
     int blockSize)
Un-pads a byte array that is padded with PKCS padding. 
 | 
abstract byte[] | 
update(byte[] bytes)
Updates the encryption context with additional input. 
 | 
abstract byte[] | 
update(byte[] bytes,
      int offset,
      int length)
Updates the encryption context with additional plaintext. 
 | 
public abstract void initEncrypt(SymmetricKey key) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, TokenException
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionTokenExceptionpublic abstract void initDecrypt(SymmetricKey key) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, TokenException
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionTokenExceptionpublic abstract void initEncrypt(SymmetricKey key, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, TokenException
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionTokenExceptionpublic abstract void initDecrypt(SymmetricKey key, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, TokenException
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionTokenExceptionpublic abstract byte[] update(byte[] bytes)
                       throws java.lang.IllegalStateException,
                              TokenException
bytes - Bytes of plaintext (if encrypting) or ciphertext (if
      decrypting).java.lang.IllegalStateExceptionTokenExceptionpublic abstract byte[] update(byte[] bytes,
            int offset,
            int length)
                       throws java.lang.IllegalStateException,
                              TokenException
bytes - Bytes of plaintext (if encrypting) or ciphertext (if
      decrypting).offset - The index in bytes at which to begin reading.length - The number of bytes from bytes to read.java.lang.IllegalStateExceptionTokenExceptionpublic abstract byte[] doFinal(byte[] bytes)
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
update may be called
  any number of times before calling final.bytes - Bytes of plaintext (if encrypting) or ciphertext (if
      decrypting).java.lang.IllegalStateExceptionIllegalBlockSizeExceptionBadPaddingExceptionTokenExceptionpublic abstract byte[] doFinal(byte[] bytes,
             int offset,
             int length)
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
bytes - Bytes of plaintext (if encrypting) or ciphertext (if
      decrypting).offset - The index in bytes at which to begin reading.length - The number of bytes from bytes to read.java.lang.IllegalStateExceptionIllegalBlockSizeExceptionBadPaddingExceptionTokenExceptionpublic abstract byte[] doFinal()
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
java.lang.IllegalStateExceptionIllegalBlockSizeExceptionBadPaddingExceptionTokenExceptionpublic static byte[] pad(byte[] toBePadded,
         int blockSize)
blockSize - The block size of the encryption algorithm.
  Must be greater than zero.unPad(byte[], int)public static byte[] unPad(byte[] padded,
           int blockSize)
                    throws BadPaddingException
blockSize - The block size of the encryption algorithm. This
      is only used for error checking: if the pad size is not
      between 1 and blockSize, a BadPaddingException is thrown.BadPaddingExceptionpad(byte[], int)public static byte[] unPad(byte[] padded)
                    throws BadPaddingException
BadPaddingExceptionpad(byte[], int)