public static OutputStream encrypt(OutputStream unencryptedOutputStream,char[] password) throws EncryptionException, IOException {
  OutputStream encryptedOutputStream=null;
  PBEKeySpec pbeKeySpec=new PBEKeySpec(password);
  PBEParameterSpec pbeParameterSpec=new PBEParameterSpec(SALT,ITERATION_COUNT);
  try {
    SecretKeyFactory secretKeyFactory=SecretKeyFactory.getInstance(ENCRYPTION_ALGORITHM,CRYPTOPROVIDER);
    SecretKey pbeKey=secretKeyFactory.generateSecret(pbeKeySpec);
    Cipher cipher=Cipher.getInstance(ENCRYPTION_ALGORITHM,CRYPTOPROVIDER);
    cipher.init(Cipher.ENCRYPT_MODE,pbeKey,pbeParameterSpec);
    encryptedOutputStream=new CipherOutputStream(unencryptedOutputStream,cipher);
  }
 catch (  GeneralSecurityException e) {
    throw new EncryptionException("There was a problem during the encryption process. See the stacktrace for details.",e);
  }
  return encryptedOutputStream;
}

public static OutputStream encrypt ( OutputStream unencryptedOutputStream , char [ ] password ) throws EncryptionException , IOException { OutputStream encryptedOutputStream = null ; PBEKeySpec pbeKeySpec = new PBEKeySpec ( password ) ; PBEParameterSpec pbeParameterSpec = new PBEParameterSpec ( SALT , ITERATION_COUNT ) ; try { SecretKeyFactory secretKeyFactory = SecretKeyFactory . getInstance ( ENCRYPTION_ALGORITHM , CRYPTOPROVIDER ) ; SecretKey pbeKey = secretKeyFactory . generateSecret ( pbeKeySpec ) ; Cipher cipher = Cipher . getInstance ( ENCRYPTION_ALGORITHM , CRYPTOPROVIDER ) ; cipher . init ( Cipher . ENCRYPT_MODE , pbeKey , pbeParameterSpec ) ; encryptedOutputStream = new CipherOutputStream ( unencryptedOutputStream , cipher ) ; } catch ( GeneralSecurityException e ) { throw new EncryptionException ( "There was a problem during the encryption process. See the stacktrace for details." , e ) ; } return encryptedOutputStream ; }
encrypts data received from the given outputstream using the aes algorithm .
