Program: 187355
Project: 187355
Buggy source:
/** 
 * Sends a message as encrypted or plain text based on the contact's state.
 * @param context The context of the class
 * @param number The number the text message is being sent to
 * @param text The text message
 * @return boolean whether the message sent or not
 */
public static boolean sendMessage(DBAccessor dba,final Context context,Entry message){
  try {
    if (dba.isTrustedContact(message.getNumber()) && ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.NATIVE_SAVE_SETTING_KEY,true) && !message.isExchange()) {
      Encryption CryptoEngine=new Encryption();
      Number number=dba.getNumber(format(message.getNumber()));
      Log.v("String_Node_Str",message.getMessage());
      final String encrypted=CryptoEngine.encrypt(number,message.getMessage());
      Log.v("String_Node_Str",encrypted);
      sendSMS(context,new Entry(message.getNumber(),encrypted,message.getId(),message.getExchange()));
      dba.updateEncryptNonce(number);
      if (ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.SHOW_ENCRYPT_SETTING_KEY,false)) {
        sendToSelf(context,message.getNumber(),encrypted,ConversationView.SENT);
        dba.addNewMessage(new Message(encrypted,true,Message.SENT_ENCRYPTED),message.getNumber(),false);
      }
      sendToSelf(context,message.getNumber(),message.getMessage(),ConversationView.SENT);
      Toast.makeText(context,R.string.encrypted_message_sent,Toast.LENGTH_SHORT).show();
    }
 else {
      sendSMS(context,message);
      sendToSelf(context,message.getNumber(),message.getMessage(),ConversationView.SENT);
      Toast.makeText(context,R.string.message_sent,Toast.LENGTH_SHORT).show();
    }
    return true;
  }
 catch (  InvalidCipherTextException e) {
    Toast.makeText(context,R.string.failed_to_encrypt,Toast.LENGTH_LONG).show();
    e.printStackTrace();
    BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    return false;
  }
catch (  final Exception e) {
    Toast.makeText(context,R.string.failed_to_sent,Toast.LENGTH_LONG).show();
    e.printStackTrace();
    BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Sends a message as encrypted or plain text based on the contact's state.
 * @param context The context of the class
 * @param number The number the text message is being sent to
 * @param text The text message
 * @return boolean whether the message sent or not
 */
public static boolean sendMessage(DBAccessor dba,final Context context,Entry message){
  try {
    if (dba.isTrustedContact(message.getNumber()) && ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.NATIVE_SAVE_SETTING_KEY,true) && !message.isExchange()) {
      if (SMSUtility.cryptoEngine == null) {
        SMSUtility.cryptoEngine=new Encryption(SMSUtility.getUser(dba,null));
      }
      Number number=dba.getNumber(format(message.getNumber()));
      Log.v("String_Node_Str",message.getMessage());
      final String encrypted=SMSUtility.cryptoEngine.encrypt(number,message.getMessage());
      Log.v("String_Node_Str",encrypted);
      sendSMS(context,new Entry(message.getNumber(),encrypted,message.getId(),message.getExchange()));
      dba.updateEncryptNonce(number);
      if (ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.SHOW_ENCRYPT_SETTING_KEY,false)) {
        sendToSelf(context,message.getNumber(),encrypted,ConversationView.SENT);
        dba.addNewMessage(new Message(encrypted,true,Message.SENT_ENCRYPTED),message.getNumber(),false);
      }
      sendToSelf(context,message.getNumber(),message.getMessage(),ConversationView.SENT);
      Toast.makeText(context,R.string.encrypted_message_sent,Toast.LENGTH_SHORT).show();
    }
 else {
      sendSMS(context,message);
      sendToSelf(context,message.getNumber(),message.getMessage(),ConversationView.SENT);
      Toast.makeText(context,R.string.message_sent,Toast.LENGTH_SHORT).show();
    }
    return true;
  }
 catch (  InvalidCipherTextException e) {
    Toast.makeText(context,R.string.failed_to_encrypt,Toast.LENGTH_LONG).show();
    e.printStackTrace();
    BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    return false;
  }
catch (  final Exception e) {
    Toast.makeText(context,R.string.failed_to_sent,Toast.LENGTH_LONG).show();
    e.printStackTrace();
    BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    return false;
  }
}