Log-In page with hashed password
up vote
0
down vote
favorite
I am quite new in Android development and hereby I would like to ask you for some help. Basically I have created the text fields of a Android Log-in page (username field & password field) and it works well without hashing a password. But now I want to use SHA256. My knowledge is still not enough to put those two together. So as follows:
public static String SHA256 (String text) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(text.getBytes());
byte digest = md.digest();
String hashedpass = Base64.encodeToString(digest, Base64.DEFAULT);
}
private JSONObject buidJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("Username", etName.getText().toString()); // <- here I get directly what I have typed in
jsonObject.accumulate("Password", hashedpass); // <- here I want to have it hashed with SHA256.
return jsonObject;
}
Could you help me with these? Thank you
java android sha256
|
show 3 more comments
up vote
0
down vote
favorite
I am quite new in Android development and hereby I would like to ask you for some help. Basically I have created the text fields of a Android Log-in page (username field & password field) and it works well without hashing a password. But now I want to use SHA256. My knowledge is still not enough to put those two together. So as follows:
public static String SHA256 (String text) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(text.getBytes());
byte digest = md.digest();
String hashedpass = Base64.encodeToString(digest, Base64.DEFAULT);
}
private JSONObject buidJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("Username", etName.getText().toString()); // <- here I get directly what I have typed in
jsonObject.accumulate("Password", hashedpass); // <- here I want to have it hashed with SHA256.
return jsonObject;
}
Could you help me with these? Thank you
java android sha256
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
yes, this is true
– V B
Nov 9 at 8:33
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am quite new in Android development and hereby I would like to ask you for some help. Basically I have created the text fields of a Android Log-in page (username field & password field) and it works well without hashing a password. But now I want to use SHA256. My knowledge is still not enough to put those two together. So as follows:
public static String SHA256 (String text) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(text.getBytes());
byte digest = md.digest();
String hashedpass = Base64.encodeToString(digest, Base64.DEFAULT);
}
private JSONObject buidJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("Username", etName.getText().toString()); // <- here I get directly what I have typed in
jsonObject.accumulate("Password", hashedpass); // <- here I want to have it hashed with SHA256.
return jsonObject;
}
Could you help me with these? Thank you
java android sha256
I am quite new in Android development and hereby I would like to ask you for some help. Basically I have created the text fields of a Android Log-in page (username field & password field) and it works well without hashing a password. But now I want to use SHA256. My knowledge is still not enough to put those two together. So as follows:
public static String SHA256 (String text) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(text.getBytes());
byte digest = md.digest();
String hashedpass = Base64.encodeToString(digest, Base64.DEFAULT);
}
private JSONObject buidJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("Username", etName.getText().toString()); // <- here I get directly what I have typed in
jsonObject.accumulate("Password", hashedpass); // <- here I want to have it hashed with SHA256.
return jsonObject;
}
Could you help me with these? Thank you
java android sha256
java android sha256
edited Nov 9 at 10:13
Kling Klang
32.2k156287
32.2k156287
asked Nov 9 at 8:22
V B
1
1
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
yes, this is true
– V B
Nov 9 at 8:33
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27
|
show 3 more comments
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
yes, this is true
– V B
Nov 9 at 8:33
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
yes, this is true
– V B
Nov 9 at 8:33
yes, this is true
– V B
Nov 9 at 8:33
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222094%2flog-in-page-with-hashed-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
looks like you are missing Java basics about how to use methods
– Vladyslav Matviienko
Nov 9 at 8:31
yes, this is true
– V B
Nov 9 at 8:33
this means that you should pass some basic Java training before starting something like you are trying to achieve. If you don't do that, you will get 1000 more questions like this.
– Vladyslav Matviienko
Nov 9 at 8:34
yes, thank you for your advise. I do this in the moment, my problem is to understand the definitions public/static/private and what can be used where. It is quite different than embedded C
– V B
Nov 9 at 8:37
Do you send this login info to a server? What do you then hope to gain by hashing the password?
– Henry
Nov 9 at 9:27