final ByteArrayOutputStream outputStream =
new ByteArrayOutputStream();
// Create a block encryptor which will help us use the triple
// des engine.
final BlockEncryptor encryptor =
new BlockEncryptor(formatterEngine, outputStream);
// Encrypt the actual data
encryptor.write(text.getBytes());
// Close the stream. This forces the extra bytes to be padded out if
// there were not enough bytes to fill all of the blocks.
encryptor.close();
// Get the actual encrypted data
final byte[] encryptedData = outputStream.toByteArray();
// End of Encryption