什么是更好地保存在Android的密码吗?内部存储或SQL数据库 [英] What is better to save a password in Android? Internal Storage or SQL database

查看:127
本文介绍了什么是更好地保存在Android的密码吗?内部存储或SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序是密码保护的,但我不能确定在哪里保存我的密码。我将使用内部存储类似下面的例子:

I am building an Android app that is password protected, but I am unsure where to save my password. Shall I use Internal Storage like an example below:

FileOutputStream foss = getActivity().openFileOutput(string,
                        Context.MODE_PRIVATE);
                foss.write(password.getBytes());
                foss.close(); 

或者我应该使用SQL数据库?

Or shall I use SQL Database?

什么是更安全,为什么?或者是有没有其他方便的方法?

What is more secure, and why? Or is there any other convenient method?

推荐答案

我会做一个共享preference。因为只有一个值,不管系统使用的是,用户或黑客可以访问它。只要你哈希,它应该能正常运行。散列基本上是单向加密。虽然嘿可能成为农行HIY可能成为7H4。因此,每一个用户输入密码时,你哈希用户输入的密码,并将其与共享preferences哈希密码,如果它们匹配,授予用户访问权限。 这里是一个线程#1散列左右在java中。

I would do it with a SharedPreference. Since there is only one value and, no matter what system you are using, the user or a hacker can access it. As long as you hash it, it should work fine. Hashing is basically one way encryption. While Hey might become abc Hiy might become 7h4. So every time the user enters a password, you hash the password the user has entered, and compare it to the hashed password in SharedPreferences, and if they match, grant the user access. Here is a Stackoverflow thread about hashing in java.

编辑:正如评论所指出的,是哈希密码在Android的一个很好的办法。使用该功能。

As comments have pointed out, this is a very good way to hash passwords in android. Use this.

这篇关于什么是更好地保存在Android的密码吗?内部存储或SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆