public static void main(String args[]) {
   Scanner scan = new Scanner(System.in);
   System.out.println("Enter a secret message: ");
   String secret = scan.nextLine();
   System.out.println("To encrypt: " + secret);
   Encryption enc = new Encryption();
   String encStr = enc.encrypt(secret); // Encrypt the original String
   System.out.println("Encrypted: " + encStr);
   String decStr = enc.decrypt(encStr);
   System.out.println("Decrypted: " + decStr); // Decrypt the encrypted string
 }
Exemplo n.º 2
0
  public int updateEntry(
      int id, String key, String value, String uris, String files, double[] location) {
    int retval;

    if (mDatabase == null) {
      retval = -1;
    } else {
      ContentValues values = new ContentValues();

      try {
        values.put(Database.C_KEY, Encryption.encrypt(mPassword, key));
        values.put(Database.C_VALUE, Encryption.encrypt(mPassword, value));
        values.put(Database.C_IMG_URI, Encryption.encrypt(mPassword, uris));
        values.put(Database.C_FILES, Encryption.encrypt(mPassword, files));
        values.put(Database.C_LAT, Encryption.encrypt(mPassword, Double.toString(location[0])));
        values.put(Database.C_LONG, Encryption.encrypt(mPassword, Double.toString(location[1])));
        values.put(Database.C_DATE, String.valueOf(System.currentTimeMillis()));
      } catch (Exception e) {
        return -1;
      }

      retval = mDatabase.update(Database.TABLE_NAME, id, values);
    }

    return retval;
  }