Store password temporarily in memory

断了今生、忘了曾经 提交于 2019-12-25 03:16:28

问题


I'm looking for a way in an Android application to store a password within the memory as long as the application is running (cf. different activities). I was first thinking about the SharedPreferences, but then it's saved in the flash memory, which isn't that good for a password, I guess.

I'm unsure, what's the best way. What would you recommend me?


回答1:


To store a password in RAM with the same lifespan as the application itself, just save the password as a static member.




回答2:


I guess you have to consider what it really means for the application (or activity) to be running. If the user navigates away from your application, it could remain in memory or its process may be terminated to reclaim resources for foreground activities. This is all transparent to the user, since if they navigate back to your application and it was previously terminated it will be re-created for them.

If the expectation is that the password will always be remembered until the user manually "exits", then I believe you must accept that the password could be written to persistent storage (if the process is killed, for instance). This doesn't mean that the password has to be stored in clear text. However, then you have the additional problem of storing the key used to protect the password.



来源:https://stackoverflow.com/questions/3031739/store-password-temporarily-in-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!