Best option to store username and password in android app

前端 未结 10 1914
深忆病人
深忆病人 2020-12-13 06:26

I am developing an Android app where the user needs to sign in to perform operations. But mostly on an android handset, people use \"Keep me signed in\", In

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 06:54

    As others have said there is no secure way to store a password in Android which protects the data fully. Hashing/encrypting the password is a great idea but all it will do is slow down the "cracker".

    With that said, this is what I did:

    1) I used this simplecryto.java class which takes a seed and a text and encrypts it. 2) I used SharedPreferences in private mode which protects the saved file in non-rooted devices. 3) The seed I used for simplecryto is an array of bytes which is a little bit harder to find by decompilers than a String.

    My application was recently reviewed by a "white hat" security group hired by my company. They flagged this issue, and indicated I should be using OAUTH but they also listed it as a LOW risk issue, which means it's not great, but not bad enough to prevent release.

    Remember that the "cracker" would need to have physical access to the device AND root it AND care enough to find the seed.

    If you really care about security, don't have a "keep me logged in" option.

提交回复
热议问题