I am currently writing an App using CodenameOne, and there is a login screen, where the user needs to insert their account and password.
Now I was wondering, what would be the best way to access the password field.
First of all, I need the password to be send to the server to get an auth-token. Sending the login credentials on start of the app is currently unencrypted, but I am not sure if this is a good idea in case of security, one could simply sniff the connection and get them plaintext. Changing this on the backend of the app is no problem, so I could also send an encrypted password to get the auth-token.
But this is not my question.
My specific question in this case is:
Let's assume I have a passwordField called passwordTextField
and can access it using getText()
.
Is it okay to encrypt it like this
String passwd = passwordTextField.getText();
String encPasswd = sha512.encrypt(passwd);
which is easier to read or would it be better to
String encPasswd = sha512.encrypt(passwordTextField.getText());
when it comes to security? Is there a difference at all?