Reputation: 49
This is a two-part question:
How do I hash the user password in an Android application and store the hash in the database?
How do I convert the user login password and check with the already stored hash in the database?
Note: I am only interested in the code related to Android (Java). If you could explain how to do this using Android Studio, that's much better.
Upvotes: 3
Views: 12566
Reputation: 1958
You can calculate the PBKDF2 function in Android hash of a string using the linked code. If you want to store the password locally, store that hashed string in a local SQL database. If you want to convert the login password, just hash the password that the user enters, and perform a SQL query in the local database to compare that new hashed password with the one stored in the database. However, I would recommend not storing the password on your phone and using a remote database instead. Depending on the DB you use, the answer for how to store and get the data will be different. However, you can still calculate the BPKDF2 hash in the same way.
Upvotes: 2