Create Chained Operations
To create a chained encryption operation:
Set the IVs you'll need for the encryption.
Obtain an instance of a chained cipher.
Create a ChainedOperations object.
Use
addEncrypt()
to add the encryption operations to theChainedOperations
object. Specify the key name, padding, andIvParameterSpec
object.Use the
seal()
method to seal theChainedOperations
object.Initialize the Cipher object, pass the
ChainedOperations
object as a parameter. For all chained operations, the first argument ofcipher.init
is ignored.Perform the operations by calling the
doFinal()
method on the Cipher object. Pass the bytes of data you want to encrypt.
Code sample
The following code sample demonstrates how to encrypt Hello World! with mykey1 and then encrypt the result with mykey2.