在Android中编写Firebase数据库而不使用其自动生成的密钥 [英] Writing Firebase Database without using their auto generated key in Android

查看:63
本文介绍了在Android中编写Firebase数据库而不使用其自动生成的密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的android项目中使用Firebase,其中每个用户都将存储他的详细信息,例如姓名,电话号码,video_url,thumbnail_url等.现在,在以前的项目中,我以前使用它的方式如下图所示-

I am using Firebase in my android project where every user will have his details stored like name, phone number, video_url, thumbnail_url etc. Now the way I have used it before in my previous projects is as shown in the pic-

我没有使用Firebase的自动生成的ID/哈希,而是使用了电子邮件ID.这样对我来说更容易.但是有人告诉我,使用电子邮件而不是自动生成的哈希/ID是不安全的,建议的方法是使用哈希.所以问题是,为了方便起见,不使用哈希而不使用电子邮件ID真的不安全吗?

I did not use the Firebase's auto generated id/Hash but used email id instead. It was easier for me that way. But someone told me that it is unsafe to use emails instead of autogenerated hash/ids and the recommended way is to use hashes. So the question is, is it really unsafe to not use hashes and use email id instead for convenience?

如果这是不安全的,如果我们不将所有键值作为对象同时插入,那么在同一哈希下写入不同键值对的推荐方法是什么?

Also if it is unsafe, what is the recommended way to write different key-value pairs under the same hash if we are not inserting all key-values at the same time as an object?

推荐答案

在更传统的数据库中使用序号的情况下,通常使用Firebase的推送ID. Firebase推送ID并不是一种安全机制,因为它们没有足够的熵以至于无法猜测.有关它们的更多信息,请参见此博客文章.

Firebase's push IDs are more typically used in situations where you'd use a sequential number in more traditional databases. Firebase push IDs are not meant as a security mechanism, as they don't contain enough entropy to be unguessable. For more about them, see this blog post and this one.

在电子邮件地址下存储数据也很常见.

Storing data under email addresses is also quite common.

这两种方法都可以是安全的,也可以是不安全的,具体取决于许多因素或您的应用程序的需求.如果有人告诉您您的数据结构不安全,我建议您问他们有什么不安全之处.

Either approach can be secure, and non-secure, depending on many factors or your app's needs. If someone told you that your data structure is unsafe, I'd recommend asking them what's unsafe about it.

这篇关于在Android中编写Firebase数据库而不使用其自动生成的密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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