cipher.init(forEncrypting, parameters);
// process ciphering
byte[] output = new byte[cipher.getOutputSize(data.length)];
int bytesProcessed1 = cipher.processBytes(data, 0, data.length, output, 0);
int bytesProcessed2 = cipher.doFinal(output, bytesProcessed1);
byte[] result = new byte[bytesProcessed1 + bytesProcessed2];
System.arraycopy(output, 0, result, 0, result.length);
return result;