Skip to content

Commit

Permalink
Implemented password field.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanmanX committed Jun 13, 2017
1 parent 1e23218 commit bbbaa51
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import dk.meznik.jan.encrypttext.util.Encryption;

public class EncryptActivity extends Activity {
EditText editTextPassword;
EditText editText1;
EditText editText2;
Button buttonEncrypt;
Expand All @@ -27,6 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_encrypt);

editTextPassword = (EditText)findViewById(R.id.editTextPassword);
editText1 = (EditText)findViewById(R.id.editText1);
editText2 = (EditText)findViewById(R.id.editText2);
buttonEncrypt = (Button)findViewById(R.id.buttonEncrypt);
Expand All @@ -47,22 +49,24 @@ public void exitWithResult(String data) {
}

public void buttonEncryptClick(View v) {
String password = editTextPassword.getText().toString();
String str = editText1.getText().toString();
String cipher = "";
try {
cipher = Encryption.encrypt("test", str);
cipher = Encryption.encrypt(password, str);
} catch (Exception ex) {
Toast.makeText(this, "could not encrypt text", Toast.LENGTH_SHORT).show();
}
editText2.setText(cipher);
}

public void buttonDecryptClick(View v) {
String password = editTextPassword.getText().toString();
String str = editText1.getText().toString();
String plain = "";
try {

plain = Encryption.decrypt("test", str);
plain = Encryption.decrypt(password, str);

} catch (Exception ex) {
Toast.makeText(this, "could not decrypt text", Toast.LENGTH_SHORT).show();
Expand Down

0 comments on commit bbbaa51

Please sign in to comment.