public String encrypt(String plainText,CharSequence password) throws KeyCrypterException {
  try {
    byte[] plainTextAsBytes;
    if (plainText == null) {
      plainTextAsBytes=new byte[0];
    }
 else {
      plainTextAsBytes=plainText.getBytes(STRING_ENCODING);
    }
    byte[] encryptedBytes=encrypt(plainTextAsBytes,password);
    byte[] encryptedBytesPlusSaltedText=concat(openSSLSaltedBytes,encryptedBytes);
    return Base64.encodeBase64String(encryptedBytesPlusSaltedText);
  }
 catch (  Exception e) {
    throw new KeyCrypterException("Could not encrypt string '" + plainText + "'",e);
  }
}

public String encrypt ( String plainText , CharSequence password ) throws KeyCrypterException { try { byte [ ] plainTextAsBytes ; if ( plainText == null ) { plainTextAsBytes = new byte [ 0 ] ; } else { plainTextAsBytes = plainText . getBytes ( STRING_ENCODING ) ; } byte [ ] encryptedBytes = encrypt ( plainTextAsBytes , password ) ; byte [ ] encryptedBytesPlusSaltedText = concat ( openSSLSaltedBytes , encryptedBytes ) ; return Base64 . encodeBase64String ( encryptedBytesPlusSaltedText ) ; } catch ( Exception e ) { throw new KeyCrypterException ( "Could not encrypt string '" + plainText + "'" , e ) ; } }
password based encryption using aes - cbc 256 bits .
