@Override public byte[] decrypt(EncryptedData dataToDecrypt,KeyParameter aesKey) throws KeyCrypterException {
  checkNotNull(dataToDecrypt);
  checkNotNull(aesKey);
  try {
    ParametersWithIV keyWithIv=new ParametersWithIV(new KeyParameter(aesKey.getKey()),dataToDecrypt.initialisationVector);
    BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false,keyWithIv);
    byte[] cipherBytes=dataToDecrypt.encryptedBytes;
    byte[] decryptedBytes=new byte[cipher.getOutputSize(cipherBytes.length)];
    final int length1=cipher.processBytes(cipherBytes,0,cipherBytes.length,decryptedBytes,0);
    final int length2=cipher.doFinal(decryptedBytes,length1);
    return Arrays.copyOf(decryptedBytes,length1 + length2);
  }
 catch (  Exception e) {
    throw new KeyCrypterException("Could not decrypt bytes",e);
  }
}

@ Override public byte [ ] decrypt ( EncryptedData dataToDecrypt , KeyParameter aesKey ) throws KeyCrypterException { checkNotNull ( dataToDecrypt ) ; checkNotNull ( aesKey ) ; try { ParametersWithIV keyWithIv = new ParametersWithIV ( new KeyParameter ( aesKey . getKey ( ) ) , dataToDecrypt . initialisationVector ) ; BufferedBlockCipher cipher = new PaddedBufferedBlockCipher ( new CBCBlockCipher ( new AESFastEngine ( ) ) ) ; cipher . init ( false , keyWithIv ) ; byte [ ] cipherBytes = dataToDecrypt . encryptedBytes ; byte [ ] decryptedBytes = new byte [ cipher . getOutputSize ( cipherBytes . length ) ] ; final int length1 = cipher . processBytes ( cipherBytes , 0 , cipherBytes . length , decryptedBytes , 0 ) ; final int length2 = cipher . doFinal ( decryptedBytes , length1 ) ; return Arrays . copyOf ( decryptedBytes , length1 + length2 ) ; } catch ( Exception e ) { throw new KeyCrypterException ( "Could not decrypt bytes" , e ) ; } }
decrypt bytes previously encrypted with this class .
