I have done login and registration activity using rest API. But in login I used only Mobile number editext. And in registration I used password. So I want to use that password in login. Means user should enter that password while he used during registraton. So how to do that?
            Asked
            
        
        
            Active
            
        
            Viewed 423 times
        
    2 Answers
0
            If you're going to store passwords, make sure you store them in EncryptedSharedPreferences. You do not have to encrypt them manually as the library will take care of it.
If you need/want more explanation on this and how it works, check out some articles about it on the web - there are plenty.
 
    
    
        Primož Ivančič
        
- 1,984
- 1
- 17
- 29
-1
            
            
        If your using Kotlin, saving password in Shared Preferences could look like this:
Initialize Shared Preferences:
var prefs: SharedPreferences
prefs = getSharedPreferences("name_of_your_file", Context.MODE_PRIVATE)
Save password to it:
with (prefs.edit()) {
    putString("password", etPasword.text)
    apply()
}
If you want to access this stored password, you can do it like this:
val password = prefs.getString("password", "default_value")
 
    
    
        blaz
        
- 69
- 1
- 5
- 
                    Actually I'm using java – Shweta S Mar 25 '22 at 08:52
- 
                    Always store the credentials as hashes. Here I found implementation of [SHA256](https://stackoverflow.com/a/55920601/6773266). You can create your own hash function too. Also I would highly recommend to use encrypted share preferences to store the credentials. I found a good example [implementation](https://stackoverflow.com/questions/62144168/how-to-implement-encrypted-sharepreferences). – mohammed ahmed Mar 25 '22 at 09:34
